mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Support video views/viewers stats in server
* Add "currentTime" and "event" body params to view endpoint * Merge watching and view endpoints * Introduce WatchAction AP activity * Add tables to store viewer information of local videos * Add endpoints to fetch video views/viewers stats of local videos * Refactor views/viewers handlers * Support "views" and "viewers" counters for both VOD and live videos
This commit is contained in:
parent
69d48ee30c
commit
b211106695
108 changed files with 2834 additions and 655 deletions
|
@ -1,6 +1,8 @@
|
|||
import express from 'express'
|
||||
import { InboxManager } from '@server/lib/activitypub/inbox-manager'
|
||||
import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler'
|
||||
import { VideoViewsBufferScheduler } from '@server/lib/schedulers/video-views-buffer-scheduler'
|
||||
import { VideoViewsManager } from '@server/lib/views/video-views-manager'
|
||||
import { Debug, SendDebugCommand } from '@shared/models'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { UserRight } from '../../../../shared/models/users'
|
||||
|
@ -38,9 +40,13 @@ function getDebug (req: express.Request, res: express.Response) {
|
|||
async function runCommand (req: express.Request, res: express.Response) {
|
||||
const body: SendDebugCommand = req.body
|
||||
|
||||
if (body.command === 'remove-dandling-resumable-uploads') {
|
||||
await RemoveDanglingResumableUploadsScheduler.Instance.execute()
|
||||
const processors: { [id in SendDebugCommand['command']]: () => Promise<any> } = {
|
||||
'remove-dandling-resumable-uploads': () => RemoveDanglingResumableUploadsScheduler.Instance.execute(),
|
||||
'process-video-views-buffer': () => VideoViewsBufferScheduler.Instance.execute(),
|
||||
'process-video-viewers': () => VideoViewsManager.Instance.processViewers()
|
||||
}
|
||||
|
||||
await processors[body.command]()
|
||||
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue