From b3148b61b72dbc96abf943ae7a9262c20a0606ca Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 8 Apr 2021 18:42:46 +0200 Subject: [PATCH] fix tests for active channel stats --- server/models/video/video-channel.ts | 4 ++-- server/tests/api/server/stats.ts | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index de80887c0a7d..b7ffbd3b136f 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -347,11 +347,11 @@ export class VideoChannelModel extends Model { } const query = ` -SELECT Count(DISTINCT("VideoChannelModel"."id")) AS "count" +SELECT COUNT(DISTINCT("VideoChannelModel"."id")) AS "count" FROM "videoChannel" AS "VideoChannelModel" INNER JOIN "video" AS "Videos" ON "VideoChannelModel"."id" = "Videos"."channelId" -AND ("Videos"."createdAt" > Now() - interval '${days}d') +AND ("Videos"."publishedAt" > Now() - interval '${days}d') INNER JOIN "account" AS "Account" ON "VideoChannelModel"."accountId" = "Account"."id" INNER JOIN "actor" AS "Account->Actor" diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts index 04063c381880..cc4eb1f947d9 100644 --- a/server/tests/api/server/stats.ts +++ b/server/tests/api/server/stats.ts @@ -145,6 +145,7 @@ describe('Test stats (excluding redundancy)', function () { it('Should have the correct active channel stats', async function () { const server = servers[0] const videoChannelProperties = { name: 'second_channel', displayName: 'My second channel' } + let videoChannel { const res = await getStats(server.url) @@ -155,7 +156,8 @@ describe('Test stats (excluding redundancy)', function () { } { - await addVideoChannel(server.url, server.accessToken, videoChannelProperties) + const resChannel = await addVideoChannel(server.url, server.accessToken, videoChannelProperties) + videoChannel = resChannel.body.videoChannel.id const res = await getStats(server.url) const data: ServerStats = res.body @@ -165,9 +167,6 @@ describe('Test stats (excluding redundancy)', function () { } { - const resChannel = await getMyUserInformation(server.url, server.accessToken) - const videoChannel = server.videoChannel = resChannel.body.videoChannels.find(v => v.name === videoChannelProperties.name) - await uploadVideo(server.url, server.accessToken, { fixture: 'video_short.webm', channelId: videoChannel.id }) const res = await getStats(server.url)