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 12, 2021
1 parent 45b1c13 commit 32beef4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 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
21 changes: 11 additions & 10 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 All @@ -31,6 +30,7 @@ const expect = chai.expect

describe('Test stats (excluding redundancy)', function () {
let servers: ServerInfo[] = []
let channelId
const user = {
username: 'user1',
password: 'super_password'
Expand Down Expand Up @@ -144,7 +144,6 @@ 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' }

{
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 All @@ -194,7 +195,7 @@ describe('Test stats (excluding redundancy)', function () {
playlistAttrs: {
displayName: 'playlist for count',
privacy: VideoPlaylistPrivacy.PUBLIC,
videoChannelId: server.videoChannel.id
videoChannelId: channelId
}
})

Expand Down Expand Up @@ -242,8 +243,8 @@ describe('Test stats (excluding redundancy)', function () {
{
const res = await getStats(servers[0].url)
const data: ServerStats = res.body
expect(data.totalLocalVideoFilesSize).to.be.greaterThan(300000)
expect(data.totalLocalVideoFilesSize).to.be.lessThan(400000)
expect(data.totalLocalVideoFilesSize).to.be.greaterThan(500000)
expect(data.totalLocalVideoFilesSize).to.be.lessThan(600000)
}
})

Expand Down

0 comments on commit 32beef4

Please sign in to comment.