ActivityPub-federated video streaming platform using P2P directly in your web browser
Don't count deleted comments for stats
Chocobozzzcb88f25ffa33
diff --git a/packages/tests/src/api/server/stats.ts b/packages/tests/src/api/server/stats.tsindex 3afe2156f2..df65990e77 100644--- a/packages/tests/src/api/server/stats.ts+++ b/packages/tests/src/api/server/stats.ts@@ -34,11 +34,14 @@ describe('Test stats (excluding redundancy)', function () {const { account } = await servers[0].users.create({ username: user.username, password: user.password })userAccountId = account.id- const { uuid } = await servers[0].videos.upload({ attributes: { fixture: 'video_short.webm' } })-- await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })-- await servers[0].views.simulateView({ id: uuid })+ {+ const { uuid } = await servers[0].videos.quickUpload({ name: 'video', fixture: 'video_short.webm' })+ await servers[0].views.simulateView({ id: uuid })++ await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })+ const toDelete = await servers[0].comments.createThread({ videoId: uuid, text: 'deleted' })+ await servers[0].comments.delete({ videoId: uuid, commentId: toDelete.id })+ }// Wait the video views repeatable jobawait wait(8000)diff --git a/server/core/models/video/video-comment.ts b/server/core/models/video/video-comment.tsindex b73dfedead..d41d7974b1 100644--- a/server/core/models/video/video-comment.ts+++ b/server/core/models/video/video-comment.ts@@ -1,3 +1,8 @@+import { pick } from '@peertube/peertube-core-utils'+import { ActivityTagObject, ActivityTombstoneObject, VideoComment, VideoCommentAdmin, VideoCommentObject } from '@peertube/peertube-models'+import { extractMentions } from '@server/helpers/mentions.js'+import { getServerActor } from '@server/models/application/application.js'+import { MAccount, MAccountId, MUserAccountId } from '@server/types/models/index.js'import { Op, Order, QueryTypes, Sequelize, Transaction } from 'sequelize'import {AllowNull,@@ -11,17 +16,12 @@ import {Table,UpdatedAt} from 'sequelize-typescript'-import { pick } from '@peertube/peertube-core-utils'-import { ActivityTagObject, ActivityTombstoneObject, VideoComment, VideoCommentAdmin, VideoCommentObject } from '@peertube/peertube-models'-import { extractMentions } from '@server/helpers/mentions.js'-import { getServerActor } from '@server/models/application/application.js'-import { MAccount, MAccountId, MUserAccountId } from '@server/types/models/index.js'import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js'import { CONSTRAINTS_FIELDS, USER_EXPORT_MAX_ITEMS } from '../../initializers/constants.js'import {MComment,- MCommentAdminFormattable,MCommentAP,+ MCommentAdminFormattable,MCommentExport,MCommentFormattable,MCommentId,@@ -480,7 +480,12 @@ export class VideoCommentModel extends SequelizeModel<VideoCommentModel> {}static async getStats () {+ const where = {+ deletedAt: null+ }+const totalLocalVideoComments = await VideoCommentModel.count({+ where,include: [{model: AccountModel.unscoped(),@@ -497,7 +502,7 @@ export class VideoCommentModel extends SequelizeModel<VideoCommentModel> {}]})- const totalVideoComments = await VideoCommentModel.count()+ const totalVideoComments = await VideoCommentModel.count({ where })return {totalLocalVideoComments,