mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-08-17 17:30:32 +03:00
Don't count deleted comments for stats
This commit is contained in:
parent
9ee1f7b57c
commit
cb88f25ffa
@ -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' } })
|
||||
{
|
||||
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' })
|
||||
|
||||
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 job
|
||||
await wait(8000)
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user