mirror of https://github.com/Chocobozzz/PeerTube
Fix abuse/registration requests stats
With old abuses/registration requests that do not have the processedAt attribute setpull/6266/head
parent
b6b1aaa56f
commit
2e760485c1
|
@ -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 New Issue