mirror of https://github.com/Chocobozzz/PeerTube
Fix my videos total counter
parent
2139365262
commit
a65858746c
|
@ -972,7 +972,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
||||||
}) {
|
}) {
|
||||||
const { accountId, channelId, start, count, sort, search, isLive } = options
|
const { accountId, channelId, start, count, sort, search, isLive } = options
|
||||||
|
|
||||||
function buildBaseQuery (): FindOptions {
|
function buildBaseQuery (forCount: boolean): FindOptions {
|
||||||
const where: WhereOptions = {}
|
const where: WhereOptions = {}
|
||||||
|
|
||||||
if (search) {
|
if (search) {
|
||||||
|
@ -1001,7 +1001,9 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
||||||
where: channelWhere,
|
where: channelWhere,
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: AccountModel,
|
model: forCount
|
||||||
|
? AccountModel.unscoped()
|
||||||
|
: AccountModel,
|
||||||
where: {
|
where: {
|
||||||
id: accountId
|
id: accountId
|
||||||
},
|
},
|
||||||
|
@ -1015,8 +1017,8 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
||||||
return baseQuery
|
return baseQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
const countQuery = buildBaseQuery()
|
const countQuery = buildBaseQuery(true)
|
||||||
const findQuery = buildBaseQuery()
|
const findQuery = buildBaseQuery(false)
|
||||||
|
|
||||||
const findScopes: (string | ScopeOptions)[] = [
|
const findScopes: (string | ScopeOptions)[] = [
|
||||||
ScopeNames.WITH_SCHEDULED_UPDATE,
|
ScopeNames.WITH_SCHEDULED_UPDATE,
|
||||||
|
|
|
@ -622,6 +622,13 @@ describe('Test users', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Should still have the same amount of videos in my account', async function () {
|
||||||
|
const { total, data } = await server.videos.listMyVideos({ token: userToken })
|
||||||
|
|
||||||
|
expect(total).to.equal(2)
|
||||||
|
expect(data).to.have.lengthOf(2)
|
||||||
|
})
|
||||||
|
|
||||||
it('Should be able to update my display name', async function () {
|
it('Should be able to update my display name', async function () {
|
||||||
await server.users.updateMe({ token: userToken, displayName: 'new display name' })
|
await server.users.updateMe({ token: userToken, displayName: 'new display name' })
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue