aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts24
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'
27import { buildNSFWFilter } from '@server/helpers/express-utils'
28import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' 27import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video'
29import { LiveManager } from '@server/lib/live/live-manager' 28import { LiveManager } from '@server/lib/live/live-manager'
30import { removeHLSObjectStorage, removeWebTorrentObjectStorage } from '@server/lib/object-storage' 29import { removeHLSObjectStorage, removeWebTorrentObjectStorage } from '@server/lib/object-storage'
@@ -134,9 +133,9 @@ import { VideoJobInfoModel } from './video-job-info'
134import { VideoLiveModel } from './video-live' 133import { VideoLiveModel } from './video-live'
135import { VideoPlaylistElementModel } from './video-playlist-element' 134import { VideoPlaylistElementModel } from './video-playlist-element'
136import { VideoShareModel } from './video-share' 135import { VideoShareModel } from './video-share'
136import { VideoSourceModel } from './video-source'
137import { VideoStreamingPlaylistModel } from './video-streaming-playlist' 137import { VideoStreamingPlaylistModel } from './video-streaming-playlist'
138import { VideoTagModel } from './video-tag' 138import { VideoTagModel } from './video-tag'
139import { VideoSourceModel } from './video-source'
140 139
141export enum ScopeNames { 140export 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,