From 630d0a1bf5897fff203cb07e426223f55dcc882d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 5 Jul 2022 15:43:21 +0200 Subject: Introduce experimental telemetry --- server/models/video/video.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'server/models') 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 { Table, UpdatedAt } from 'sequelize-typescript' -import { buildNSFWFilter } from '@server/helpers/express-utils' import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' import { LiveManager } from '@server/lib/live/live-manager' import { removeHLSObjectStorage, removeWebTorrentObjectStorage } from '@server/lib/object-storage' @@ -134,9 +133,9 @@ import { VideoJobInfoModel } from './video-job-info' import { VideoLiveModel } from './video-live' import { VideoPlaylistElementModel } from './video-playlist-element' import { VideoShareModel } from './video-share' +import { VideoSourceModel } from './video-source' import { VideoStreamingPlaylistModel } from './video-streaming-playlist' import { VideoTagModel } from './video-tag' -import { VideoSourceModel } from './video-source' export enum ScopeNames { FOR_API = 'FOR_API', @@ -1370,11 +1369,7 @@ export class VideoModel extends Model>> { } static async getStats () { - const totalLocalVideos = await VideoModel.count({ - where: { - remote: false - } - }) + const serverActor = await getServerActor() let totalLocalVideoViews = await VideoModel.sum('views', { where: { @@ -1385,19 +1380,26 @@ export class VideoModel extends Model>> { // Sequelize could return null... if (!totalLocalVideoViews) totalLocalVideoViews = 0 - const serverActor = await getServerActor() - - const { total: totalVideos } = await VideoModel.listForApi({ + const baseOptions = { start: 0, count: 0, sort: '-publishedAt', - nsfw: buildNSFWFilter(), + nsfw: null, + isLocal: true, displayOnlyForFollower: { actorId: serverActor.id, orLocalVideos: true } + } + + const { total: totalLocalVideos } = await VideoModel.listForApi({ + ...baseOptions, + + isLocal: true }) + const { total: totalVideos } = await VideoModel.listForApi(baseOptions) + return { totalLocalVideos, totalLocalVideoViews, -- cgit v1.2.3