diff options
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video.ts | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index e5f8b5fa2..4f711b2fa 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -24,7 +24,6 @@ import { | |||
24 | Table, | 24 | Table, |
25 | UpdatedAt | 25 | UpdatedAt |
26 | } from 'sequelize-typescript' | 26 | } from 'sequelize-typescript' |
27 | import { buildNSFWFilter } from '@server/helpers/express-utils' | ||
28 | import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' | 27 | import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' |
29 | import { LiveManager } from '@server/lib/live/live-manager' | 28 | import { LiveManager } from '@server/lib/live/live-manager' |
30 | import { removeHLSObjectStorage, removeWebTorrentObjectStorage } from '@server/lib/object-storage' | 29 | import { removeHLSObjectStorage, removeWebTorrentObjectStorage } from '@server/lib/object-storage' |
@@ -134,9 +133,9 @@ import { VideoJobInfoModel } from './video-job-info' | |||
134 | import { VideoLiveModel } from './video-live' | 133 | import { VideoLiveModel } from './video-live' |
135 | import { VideoPlaylistElementModel } from './video-playlist-element' | 134 | import { VideoPlaylistElementModel } from './video-playlist-element' |
136 | import { VideoShareModel } from './video-share' | 135 | import { VideoShareModel } from './video-share' |
136 | import { VideoSourceModel } from './video-source' | ||
137 | import { VideoStreamingPlaylistModel } from './video-streaming-playlist' | 137 | import { VideoStreamingPlaylistModel } from './video-streaming-playlist' |
138 | import { VideoTagModel } from './video-tag' | 138 | import { VideoTagModel } from './video-tag' |
139 | import { VideoSourceModel } from './video-source' | ||
140 | 139 | ||
141 | export enum ScopeNames { | 140 | export enum ScopeNames { |
142 | FOR_API = 'FOR_API', | 141 | FOR_API = 'FOR_API', |
@@ -1370,11 +1369,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
1370 | } | 1369 | } |
1371 | 1370 | ||
1372 | static async getStats () { | 1371 | static async getStats () { |
1373 | const totalLocalVideos = await VideoModel.count({ | 1372 | const serverActor = await getServerActor() |
1374 | where: { | ||
1375 | remote: false | ||
1376 | } | ||
1377 | }) | ||
1378 | 1373 | ||
1379 | let totalLocalVideoViews = await VideoModel.sum('views', { | 1374 | let totalLocalVideoViews = await VideoModel.sum('views', { |
1380 | where: { | 1375 | where: { |
@@ -1385,19 +1380,26 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
1385 | // Sequelize could return null... | 1380 | // Sequelize could return null... |
1386 | if (!totalLocalVideoViews) totalLocalVideoViews = 0 | 1381 | if (!totalLocalVideoViews) totalLocalVideoViews = 0 |
1387 | 1382 | ||
1388 | const serverActor = await getServerActor() | 1383 | const baseOptions = { |
1389 | |||
1390 | const { total: totalVideos } = await VideoModel.listForApi({ | ||
1391 | start: 0, | 1384 | start: 0, |
1392 | count: 0, | 1385 | count: 0, |
1393 | sort: '-publishedAt', | 1386 | sort: '-publishedAt', |
1394 | nsfw: buildNSFWFilter(), | 1387 | nsfw: null, |
1388 | isLocal: true, | ||
1395 | displayOnlyForFollower: { | 1389 | displayOnlyForFollower: { |
1396 | actorId: serverActor.id, | 1390 | actorId: serverActor.id, |
1397 | orLocalVideos: true | 1391 | orLocalVideos: true |
1398 | } | 1392 | } |
1393 | } | ||
1394 | |||
1395 | const { total: totalLocalVideos } = await VideoModel.listForApi({ | ||
1396 | ...baseOptions, | ||
1397 | |||
1398 | isLocal: true | ||
1399 | }) | 1399 | }) |
1400 | 1400 | ||
1401 | const { total: totalVideos } = await VideoModel.listForApi(baseOptions) | ||
1402 | |||
1401 | return { | 1403 | return { |
1402 | totalLocalVideos, | 1404 | totalLocalVideos, |
1403 | totalLocalVideoViews, | 1405 | totalLocalVideoViews, |