mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
Add abuse and registration requests stats
This commit is contained in:
parent
fbe47a9f8e
commit
db69d9491e
25 changed files with 638 additions and 227 deletions
|
@ -9,6 +9,9 @@ import { VideoCommentModel } from '@server/models/video/video-comment.js'
|
|||
import { VideoFileModel } from '@server/models/video/video-file.js'
|
||||
import { VideoPlaylistModel } from '@server/models/video/video-playlist.js'
|
||||
import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@peertube/peertube-models'
|
||||
import { UserRegistrationModel } from '@server/models/user/user-registration.js'
|
||||
import { AbuseModel } from '@server/models/abuse/abuse.js'
|
||||
import { pick } from '@peertube/peertube-core-utils'
|
||||
|
||||
class StatsManager {
|
||||
|
||||
|
@ -85,6 +88,9 @@ class StatsManager {
|
|||
|
||||
videosRedundancy: videosRedundancyStats,
|
||||
|
||||
...await this.buildAbuseStats(),
|
||||
...await this.buildRegistrationRequestsStats(),
|
||||
|
||||
...this.buildAPStats()
|
||||
}
|
||||
|
||||
|
@ -170,6 +176,34 @@ class StatsManager {
|
|||
}
|
||||
}
|
||||
|
||||
private async buildRegistrationRequestsStats () {
|
||||
if (!CONFIG.STATS.REGISTRATION_REQUESTS.ENABLED) {
|
||||
return {
|
||||
averageRegistrationRequestResponseTimeMs: null,
|
||||
totalRegistrationRequests: null,
|
||||
totalRegistrationRequestsProcessed: null
|
||||
}
|
||||
}
|
||||
|
||||
const res = await UserRegistrationModel.getStats()
|
||||
|
||||
return pick(res, [ 'averageRegistrationRequestResponseTimeMs', 'totalRegistrationRequests', 'totalRegistrationRequestsProcessed' ])
|
||||
}
|
||||
|
||||
private async buildAbuseStats () {
|
||||
if (!CONFIG.STATS.ABUSES.ENABLED) {
|
||||
return {
|
||||
averageAbuseResponseTimeMs: null,
|
||||
totalAbuses: null,
|
||||
totalAbusesProcessed: null
|
||||
}
|
||||
}
|
||||
|
||||
const res = await AbuseModel.getStats()
|
||||
|
||||
return pick(res, [ 'averageAbuseResponseTimeMs', 'totalAbuses', 'totalAbusesProcessed' ])
|
||||
}
|
||||
|
||||
static get Instance () {
|
||||
return this.instance || (this.instance = new this())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue