Fix channels list count
This commit is contained in:
parent
9ca5728be1
commit
43fc899a10
|
@ -143,28 +143,28 @@ export type SummaryOptions = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const channelInclude: Includeable[] = []
|
const channelActorInclude: Includeable[] = []
|
||||||
const accountInclude: Includeable[] = []
|
const accountActorInclude: Includeable[] = []
|
||||||
|
|
||||||
if (options.forCount !== true) {
|
if (options.forCount !== true) {
|
||||||
accountInclude.push({
|
accountActorInclude.push({
|
||||||
model: ServerModel,
|
model: ServerModel,
|
||||||
required: false
|
required: false
|
||||||
})
|
})
|
||||||
|
|
||||||
accountInclude.push({
|
accountActorInclude.push({
|
||||||
model: ActorImageModel,
|
model: ActorImageModel,
|
||||||
as: 'Avatars',
|
as: 'Avatars',
|
||||||
required: false
|
required: false
|
||||||
})
|
})
|
||||||
|
|
||||||
channelInclude.push({
|
channelActorInclude.push({
|
||||||
model: ActorImageModel,
|
model: ActorImageModel,
|
||||||
as: 'Avatars',
|
as: 'Avatars',
|
||||||
required: false
|
required: false
|
||||||
})
|
})
|
||||||
|
|
||||||
channelInclude.push({
|
channelActorInclude.push({
|
||||||
model: ActorImageModel,
|
model: ActorImageModel,
|
||||||
as: 'Banners',
|
as: 'Banners',
|
||||||
required: false
|
required: false
|
||||||
|
@ -172,7 +172,7 @@ export type SummaryOptions = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.forCount !== true || serverRequired) {
|
if (options.forCount !== true || serverRequired) {
|
||||||
channelInclude.push({
|
channelActorInclude.push({
|
||||||
model: ServerModel,
|
model: ServerModel,
|
||||||
duplicating: false,
|
duplicating: false,
|
||||||
required: serverRequired,
|
required: serverRequired,
|
||||||
|
@ -190,7 +190,7 @@ export type SummaryOptions = {
|
||||||
where: {
|
where: {
|
||||||
[Op.and]: whereActorAnd
|
[Op.and]: whereActorAnd
|
||||||
},
|
},
|
||||||
include: channelInclude
|
include: channelActorInclude
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: AccountModel.unscoped(),
|
model: AccountModel.unscoped(),
|
||||||
|
@ -202,7 +202,7 @@ export type SummaryOptions = {
|
||||||
},
|
},
|
||||||
model: ActorModel.unscoped(),
|
model: ActorModel.unscoped(),
|
||||||
required: true,
|
required: true,
|
||||||
include: accountInclude
|
include: accountActorInclude
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -605,17 +605,17 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const scopes: string | ScopeOptions | (string | ScopeOptions)[] = [ ScopeNames.WITH_ACTOR_BANNER ]
|
const findScopes: string | ScopeOptions | (string | ScopeOptions)[] = [ ScopeNames.WITH_ACTOR_BANNER ]
|
||||||
|
|
||||||
if (options.withStats === true) {
|
if (options.withStats === true) {
|
||||||
scopes.push({
|
findScopes.push({
|
||||||
method: [ ScopeNames.WITH_STATS, { daysPrior: 30 } as AvailableWithStatsOptions ]
|
method: [ ScopeNames.WITH_STATS, { daysPrior: 30 } as AvailableWithStatsOptions ]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
VideoChannelModel.scope(scopes).count(getQuery(true)),
|
VideoChannelModel.unscoped().count(getQuery(true)),
|
||||||
VideoChannelModel.scope(scopes).findAll(getQuery(false))
|
VideoChannelModel.scope(findScopes).findAll(getQuery(false))
|
||||||
]).then(([ total, data ]) => ({ total, data }))
|
]).then(([ total, data ]) => ({ total, data }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -325,6 +325,24 @@ describe('Test video channels', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Should still correctly list channels', async function () {
|
||||||
|
{
|
||||||
|
const body = await servers[0].channels.list({ start: 1, count: 1, sort: 'createdAt' })
|
||||||
|
|
||||||
|
expect(body.total).to.equal(3)
|
||||||
|
expect(body.data).to.have.lengthOf(1)
|
||||||
|
expect(body.data[0].name).to.equal('second_video_channel')
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const body = await servers[0].channels.listByAccount({ accountName, start: 1, count: 1, sort: 'createdAt' })
|
||||||
|
|
||||||
|
expect(body.total).to.equal(2)
|
||||||
|
expect(body.data).to.have.lengthOf(1)
|
||||||
|
expect(body.data[0].name).to.equal('second_video_channel')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
it('Should delete the video channel avatar', async function () {
|
it('Should delete the video channel avatar', async function () {
|
||||||
this.timeout(15000)
|
this.timeout(15000)
|
||||||
await servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'avatar' })
|
await servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'avatar' })
|
||||||
|
|
Loading…
Reference in New Issue
Block a user