X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fstat-manager.ts;h=03063793d8121695bb5864755086545d80021341;hb=ccd62a45024d90c004d0d38737fef055b3fe22b7;hp=547d7a56b57b5338e3a426c123c1b3cf314b5e68;hpb=543442a3be9d7740749eb3918dc59f502ff042f9;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/stat-manager.ts b/server/lib/stat-manager.ts index 547d7a56b..03063793d 100644 --- a/server/lib/stat-manager.ts +++ b/server/lib/stat-manager.ts @@ -1,10 +1,13 @@ +import { mapSeries } from 'bluebird' import { CONFIG } from '@server/initializers/config' -import { UserModel } from '@server/models/account/user' -import { ActorFollowModel } from '@server/models/activitypub/actor-follow' +import { ActorFollowModel } from '@server/models/actor/actor-follow' import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' +import { UserModel } from '@server/models/user/user' import { VideoModel } from '@server/models/video/video' +import { VideoChannelModel } from '@server/models/video/video-channel' import { VideoCommentModel } from '@server/models/video/video-comment' import { VideoFileModel } from '@server/models/video/video-file' +import { VideoPlaylistModel } from '@server/models/video/video-playlist' import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@shared/models' class StatsManager { @@ -46,21 +49,36 @@ class StatsManager { const { totalUsers, totalDailyActiveUsers, totalWeeklyActiveUsers, totalMonthlyActiveUsers } = await UserModel.getStats() const { totalInstanceFollowers, totalInstanceFollowing } = await ActorFollowModel.getStats() const { totalLocalVideoFilesSize } = await VideoFileModel.getStats() + const { + totalLocalVideoChannels, + totalLocalDailyActiveVideoChannels, + totalLocalWeeklyActiveVideoChannels, + totalLocalMonthlyActiveVideoChannels + } = await VideoChannelModel.getStats() + const { totalLocalPlaylists } = await VideoPlaylistModel.getStats() const videosRedundancyStats = await this.buildRedundancyStats() const data: ServerStats = { + totalUsers, + totalDailyActiveUsers, + totalWeeklyActiveUsers, + totalMonthlyActiveUsers, + totalLocalVideos, totalLocalVideoViews, - totalLocalVideoFilesSize, totalLocalVideoComments, + totalLocalVideoFilesSize, + totalVideos, totalVideoComments, - totalUsers, - totalDailyActiveUsers, - totalWeeklyActiveUsers, - totalMonthlyActiveUsers, + totalLocalVideoChannels, + totalLocalDailyActiveVideoChannels, + totalLocalWeeklyActiveVideoChannels, + totalLocalMonthlyActiveVideoChannels, + + totalLocalPlaylists, totalInstanceFollowers, totalInstanceFollowing, @@ -89,12 +107,10 @@ class StatsManager { strategies.push({ strategy: 'manual', size: null }) - return Promise.all( - strategies.map(r => { - return VideoRedundancyModel.getStats(r.strategy) - .then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size })) - }) - ) + return mapSeries(strategies, r => { + return VideoRedundancyModel.getStats(r.strategy) + .then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size })) + }) } private buildAPPerType () {