const { totalInstanceFollowers, totalInstanceFollowing } = await ActorFollowModel.getStats()
const { totalLocalVideoFilesSize } = await VideoFileModel.getStats()
- const strategies: { strategy: VideoRedundancyStrategyWithManual, size: number }[] = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES
- .map(r => ({
- strategy: r.strategy,
- size: r.size
- }))
+ 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(
import { getHLSDirectory, getTorrentFileName, getTorrentFilePath, getVideoFilename, getVideoFilePath } from '@server/lib/video-paths'
import { ModelCache } from '@server/models/model-cache'
import { buildListQuery, BuildVideosQueryOptions, wrapForAPIResults } from './video-query-builder'
+import { buildNSFWFilter } from '@server/helpers/express-utils'
export enum ScopeNames {
AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS',
remote: false
}
})
- const totalVideos = await VideoModel.count()
let totalLocalVideoViews = await VideoModel.sum('views', {
where: {
remote: false
}
})
+
// Sequelize could return null...
if (!totalLocalVideoViews) totalLocalVideoViews = 0
+ const { total: totalVideos } = await VideoModel.listForApi({
+ start: 0,
+ count: 0,
+ sort: '-publishedAt',
+ nsfw: buildNSFWFilter(),
+ includeLocalVideos: true,
+ withFiles: false
+ })
+
return {
totalLocalVideos,
totalLocalVideoViews,
}
function getModels () {
+ if (options.count === 0) return Promise.resolve([])
+
const { query, replacements, order } = buildListQuery(VideoModel, options)
const queryModels = wrapForAPIResults(query, replacements, options, order)
doubleFollow,
flushAndRunMultipleServers,
follow,
- ServerInfo,
+ ServerInfo, unfollow,
uploadVideo,
viewVideo,
wait
expect(data.totalInstanceFollowers).to.equal(0)
})
+ it('Should have the correct total videos stats after an unfollow', async function () {
+ await unfollow(servers[2].url, servers[2].accessToken, servers[0])
+ await waitJobs(servers)
+
+ const res = await getStats(servers[2].url)
+ const data: ServerStats = res.body
+
+ expect(data.totalVideos).to.equal(0)
+ })
+
after(async function () {
await cleanupTests(servers)
})