mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-11-26 10:40:28 -06:00
Skip counting for recommended videos
This commit is contained in:
parent
cb38deb288
commit
360439088d
@ -61,6 +61,7 @@ export class RecentVideosRecommendationService implements RecommendationService
|
||||
return this.searchService.searchVideos({
|
||||
search: '',
|
||||
componentPagination: pagination,
|
||||
skipCount: true,
|
||||
advancedSearch: new AdvancedSearch({
|
||||
tagsOneOf: recommendation.tags.join(','),
|
||||
sort: '-publishedAt',
|
||||
|
@ -31,8 +31,9 @@ export class SearchService {
|
||||
componentPagination?: ComponentPaginationLight
|
||||
advancedSearch?: AdvancedSearch
|
||||
uuids?: string[]
|
||||
skipCount?: boolean
|
||||
}): Observable<ResultList<Video>> {
|
||||
const { search, uuids, componentPagination, advancedSearch } = parameters
|
||||
const { search, uuids, componentPagination, advancedSearch, skipCount } = parameters
|
||||
|
||||
if (advancedSearch?.resultType !== undefined && advancedSearch.resultType !== 'videos') {
|
||||
return of({ total: 0, data: [] })
|
||||
@ -49,6 +50,7 @@ export class SearchService {
|
||||
params = this.restService.addRestGetParams(params, pagination)
|
||||
|
||||
if (search) params = params.append('search', search)
|
||||
if (skipCount === true) params = params.append('skipCount', true)
|
||||
if (uuids) params = this.restService.addArrayParams(params, 'uuids', uuids)
|
||||
|
||||
if (advancedSearch) {
|
||||
|
@ -10,7 +10,7 @@ import { Hooks } from '@server/lib/plugins/hooks.js'
|
||||
import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search.js'
|
||||
import { getServerActor } from '@server/models/application/application.js'
|
||||
import { HttpStatusCode, ResultList, Video, VideosSearchQueryAfterSanitize } from '@peertube/peertube-models'
|
||||
import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils.js'
|
||||
import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils.js'
|
||||
import { logger } from '../../../helpers/logger.js'
|
||||
import { getFormattedObjects } from '../../../helpers/utils.js'
|
||||
import {
|
||||
@ -61,7 +61,7 @@ function searchVideos (req: express.Request, res: express.Response) {
|
||||
return searchVideosIndex(query, res)
|
||||
}
|
||||
|
||||
return searchVideosDB(query, res)
|
||||
return searchVideosDB(query, req, res)
|
||||
}
|
||||
|
||||
async function searchVideosIndex (query: VideosSearchQueryAfterSanitize, res: express.Response) {
|
||||
@ -101,7 +101,7 @@ async function searchVideosIndex (query: VideosSearchQueryAfterSanitize, res: ex
|
||||
}
|
||||
}
|
||||
|
||||
async function searchVideosDB (query: VideosSearchQueryAfterSanitize, res: express.Response) {
|
||||
async function searchVideosDB (query: VideosSearchQueryAfterSanitize, req: express.Request, res: express.Response) {
|
||||
const serverActor = await getServerActor()
|
||||
|
||||
const apiOptions = await Hooks.wrapObject({
|
||||
@ -112,6 +112,8 @@ async function searchVideosDB (query: VideosSearchQueryAfterSanitize, res: expre
|
||||
orLocalVideos: true
|
||||
},
|
||||
|
||||
countVideos: getCountVideos(req),
|
||||
|
||||
nsfw: buildNSFWFilter(res, query.nsfw),
|
||||
user: res.locals.oauth
|
||||
? res.locals.oauth.token.User
|
||||
|
@ -1241,6 +1241,8 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
||||
uuids?: string[]
|
||||
|
||||
excludeAlreadyWatched?: boolean
|
||||
|
||||
countVideos?: boolean
|
||||
}) {
|
||||
VideoModel.throwIfPrivateIncludeWithoutUser(options.include, options.user)
|
||||
VideoModel.throwIfPrivacyOneOfWithoutUser(options.privacyOneOf, options.user)
|
||||
@ -1281,7 +1283,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
||||
serverAccountIdForBlock: serverActor.Account.id
|
||||
}
|
||||
|
||||
return VideoModel.getAvailableForApi(queryOptions)
|
||||
return VideoModel.getAvailableForApi(queryOptions, options.countVideos)
|
||||
}
|
||||
|
||||
static countLives (options: {
|
||||
|
Loading…
Reference in New Issue
Block a user