-async function getStats (req: express.Request, res: express.Response) {
- const { totalLocalVideos, totalLocalVideoViews, totalVideos } = await VideoModel.getStats()
- const { totalLocalVideoComments, totalVideoComments } = await VideoCommentModel.getStats()
- const { totalUsers } = await UserModel.getStats()
- const { totalInstanceFollowers, totalInstanceFollowing } = await ActorFollowModel.getStats()
- const { totalLocalVideoFilesSize } = await VideoFileModel.getStats()
-
- const strategies: { strategy: VideoRedundancyStrategyWithManual, size: number }[] = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES
- .map(r => ({
- strategy: r.strategy,
- size: r.size
- }))
- strategies.push({ strategy: 'manual', size: null })
-
- const videosRedundancyStats = await Promise.all(
- strategies.map(r => {
- return VideoRedundancyModel.getStats(r.strategy)
- .then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size }))
- })
- )
-
- const data: ServerStats = {
- totalLocalVideos,
- totalLocalVideoViews,
- totalLocalVideoFilesSize,
- totalLocalVideoComments,
- totalVideos,
- totalVideoComments,
- totalUsers,
- totalInstanceFollowers,
- totalInstanceFollowing,
- videosRedundancy: videosRedundancyStats
- }