Fix abuse/registration requests stats
With old abuses/registration requests that do not have the processedAt attribute set
This commit is contained in:
parent
b6b1aaa56f
commit
2e760485c1
2 changed files with 7 additions and 4 deletions
|
@ -10,7 +10,8 @@ import {
|
|||
AdminVideoCommentAbuse,
|
||||
UserAbuse,
|
||||
UserVideoAbuse,
|
||||
type AbuseStateType
|
||||
type AbuseStateType,
|
||||
AbuseState
|
||||
} from '@peertube/peertube-models'
|
||||
import { isAbuseModerationCommentValid, isAbuseReasonValid, isAbuseStateValid } from '@server/helpers/custom-validators/abuses.js'
|
||||
import invert from 'lodash-es/invert.js'
|
||||
|
@ -449,7 +450,8 @@ export class AbuseModel extends SequelizeModel<AbuseModel> {
|
|||
`AVG(EXTRACT(EPOCH FROM ("processedAt" - "createdAt") * 1000)) ` +
|
||||
`FILTER (WHERE "processedAt" IS NOT NULL AND "createdAt" > CURRENT_DATE - INTERVAL '3 months')` +
|
||||
`AS "avgResponseTime", ` +
|
||||
`COUNT(*) FILTER (WHERE "processedAt" IS NOT NULL) AS "processedAbuses", ` +
|
||||
// "processedAt" has been introduced in PeerTube 6.1 so also check the abuse state to check processed abuses
|
||||
`COUNT(*) FILTER (WHERE "processedAt" IS NOT NULL OR "state" != ${AbuseState.PENDING}) AS "processedAbuses", ` +
|
||||
`COUNT(*) AS "totalAbuses" ` +
|
||||
`FROM "abuse"`
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { UserRegistration, type UserRegistrationStateType } from '@peertube/peertube-models'
|
||||
import { UserRegistration, UserRegistrationState, type UserRegistrationStateType } from '@peertube/peertube-models'
|
||||
import {
|
||||
isRegistrationModerationResponseValid,
|
||||
isRegistrationReasonValid,
|
||||
|
@ -234,7 +234,8 @@ export class UserRegistrationModel extends SequelizeModel<UserRegistrationModel>
|
|||
`AVG(EXTRACT(EPOCH FROM ("processedAt" - "createdAt") * 1000)) ` +
|
||||
`FILTER (WHERE "processedAt" IS NOT NULL AND "createdAt" > CURRENT_DATE - INTERVAL '3 months')` +
|
||||
`AS "avgResponseTime", ` +
|
||||
`COUNT(*) FILTER (WHERE "processedAt" IS NOT NULL) AS "processedRequests", ` +
|
||||
// "processedAt" has been introduced in PeerTube 6.1 so also check the abuse state to check processed abuses
|
||||
`COUNT(*) FILTER (WHERE "processedAt" IS NOT NULL OR "state" != ${UserRegistrationState.PENDING}) AS "processedRequests", ` +
|
||||
`COUNT(*) AS "totalRequests" ` +
|
||||
`FROM "userRegistration"`
|
||||
|
||||
|
|
Loading…
Reference in a new issue