Skip to content

Commit

Permalink
fix tests for active channel stats
Browse files Browse the repository at this point in the history
  • Loading branch information
rigelk committed Apr 9, 2021
1 parent eeeb43b commit 3cf962e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions server/models/video/video-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 8 additions & 7 deletions server/tests/api/server/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
doubleFollow,
flushAndRunMultipleServers,
follow,
getMyUserInformation,
ServerInfo,
unfollow,
updateCustomSubConfig,
Expand Down Expand Up @@ -144,7 +143,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 channelId

{
const res = await getStats(server.url)
Expand All @@ -155,7 +154,12 @@ describe('Test stats (excluding redundancy)', function () {
}

{
await addVideoChannel(server.url, server.accessToken, videoChannelProperties)
const channelAttributes = {
name: 'stats_channel',
displayName: 'My stats channel'
}
const resChannel = await addVideoChannel(server.url, server.accessToken, channelAttributes)
channelId = resChannel.body.videoChannel.id

const res = await getStats(server.url)
const data: ServerStats = res.body
Expand All @@ -165,10 +169,7 @@ 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 })
await uploadVideo(server.url, server.accessToken, { fixture: 'video_short.webm', channelId })

const res = await getStats(server.url)
const data: ServerStats = res.body
Expand Down

0 comments on commit 3cf962e

Please sign in to comment.