mirror of https://github.com/Chocobozzz/PeerTube
Don't count deleted comments for stats
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 })
|
const { account } = await servers[0].users.create({ username: user.username, password: user.password })
|
||||||
userAccountId = account.id
|
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].comments.createThread({ videoId: uuid, text: 'comment' })
|
||||||
|
const toDelete = await servers[0].comments.createThread({ videoId: uuid, text: 'deleted' })
|
||||||
await servers[0].views.simulateView({ id: uuid })
|
await servers[0].comments.delete({ videoId: uuid, commentId: toDelete.id })
|
||||||
|
}
|
||||||
|
|
||||||
// Wait the video views repeatable job
|
// Wait the video views repeatable job
|
||||||
await wait(8000)
|
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 { Op, Order, QueryTypes, Sequelize, Transaction } from 'sequelize'
|
||||||
import {
|
import {
|
||||||
AllowNull,
|
AllowNull,
|
||||||
|
@ -11,17 +16,12 @@ import {
|
||||||
Table,
|
Table,
|
||||||
UpdatedAt
|
UpdatedAt
|
||||||
} from 'sequelize-typescript'
|
} 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 { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js'
|
||||||
import { CONSTRAINTS_FIELDS, USER_EXPORT_MAX_ITEMS } from '../../initializers/constants.js'
|
import { CONSTRAINTS_FIELDS, USER_EXPORT_MAX_ITEMS } from '../../initializers/constants.js'
|
||||||
import {
|
import {
|
||||||
MComment,
|
MComment,
|
||||||
MCommentAdminFormattable,
|
|
||||||
MCommentAP,
|
MCommentAP,
|
||||||
|
MCommentAdminFormattable,
|
||||||
MCommentExport,
|
MCommentExport,
|
||||||
MCommentFormattable,
|
MCommentFormattable,
|
||||||
MCommentId,
|
MCommentId,
|
||||||
|
@ -480,7 +480,12 @@ export class VideoCommentModel extends SequelizeModel<VideoCommentModel> {
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getStats () {
|
static async getStats () {
|
||||||
|
const where = {
|
||||||
|
deletedAt: null
|
||||||
|
}
|
||||||
|
|
||||||
const totalLocalVideoComments = await VideoCommentModel.count({
|
const totalLocalVideoComments = await VideoCommentModel.count({
|
||||||
|
where,
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: AccountModel.unscoped(),
|
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 {
|
return {
|
||||||
totalLocalVideoComments,
|
totalLocalVideoComments,
|
||||||
|
|
Loading…
Reference in New Issue