]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/server/stats.ts
Fix total videos stats
[github/Chocobozzz/PeerTube.git] / server / controllers / api / server / stats.ts
index 89ffd1717a8e609de92c68823e76f2864f97553f..f6a85d0c066d3cebcdd4cb209586ece23e853890 100644 (file)
@@ -6,14 +6,16 @@ import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
 import { VideoModel } from '../../../models/video/video'
 import { VideoCommentModel } from '../../../models/video/video-comment'
 import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy'
-import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../../initializers/constants'
+import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants'
 import { cacheRoute } from '../../../middlewares/cache'
 import { VideoFileModel } from '../../../models/video/video-file'
+import { CONFIG } from '../../../initializers/config'
+import { VideoRedundancyStrategyWithManual } from '@shared/models'
 
 const statsRouter = express.Router()
 
 statsRouter.get('/stats',
-  asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.STATS)),
+  asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.STATS)),
   asyncMiddleware(getStats)
 )
 
@@ -24,8 +26,16 @@ async function getStats (req: express.Request, res: express.Response) {
   const { totalInstanceFollowers, totalInstanceFollowing } = await ActorFollowModel.getStats()
   const { totalLocalVideoFilesSize } = await VideoFileModel.getStats()
 
+  const strategies = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES
+                          .map(r => ({
+                            strategy: r.strategy as VideoRedundancyStrategyWithManual,
+                            size: r.size
+                          }))
+
+  strategies.push({ strategy: 'manual', size: null })
+
   const videosRedundancyStats = await Promise.all(
-    CONFIG.REDUNDANCY.VIDEOS.STRATEGIES.map(r => {
+    strategies.map(r => {
       return VideoRedundancyModel.getStats(r.strategy)
         .then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size }))
     })