mirror of https://github.com/Chocobozzz/PeerTube
Fix trending videos count
parent
74d6346935
commit
8ea6f49ad7
|
@ -1200,7 +1200,19 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const { count, rows: rowsId } = await VideoModel.scope(idsScope).findAndCountAll(query)
|
// Remove trending sort on count, because it uses a group by
|
||||||
|
const countOptions = Object.assign({}, options, { trendingDays: undefined })
|
||||||
|
const countQuery = Object.assign({}, query, { attributes: undefined, group: undefined })
|
||||||
|
const countScope = {
|
||||||
|
method: [
|
||||||
|
ScopeNames.AVAILABLE_FOR_LIST_IDS, countOptions
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
const [ count, rowsId ] = await Promise.all([
|
||||||
|
VideoModel.scope(countScope).count(countQuery),
|
||||||
|
VideoModel.scope(idsScope).findAll(query)
|
||||||
|
])
|
||||||
const ids = rowsId.map(r => r.id)
|
const ids = rowsId.map(r => r.id)
|
||||||
|
|
||||||
if (ids.length === 0) return { data: [], total: count }
|
if (ids.length === 0) return { data: [], total: count }
|
||||||
|
|
Loading…
Reference in New Issue