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({
|
return this.searchService.searchVideos({
|
||||||
search: '',
|
search: '',
|
||||||
componentPagination: pagination,
|
componentPagination: pagination,
|
||||||
|
skipCount: true,
|
||||||
advancedSearch: new AdvancedSearch({
|
advancedSearch: new AdvancedSearch({
|
||||||
tagsOneOf: recommendation.tags.join(','),
|
tagsOneOf: recommendation.tags.join(','),
|
||||||
sort: '-publishedAt',
|
sort: '-publishedAt',
|
||||||
|
|
|
@ -31,8 +31,9 @@ export class SearchService {
|
||||||
componentPagination?: ComponentPaginationLight
|
componentPagination?: ComponentPaginationLight
|
||||||
advancedSearch?: AdvancedSearch
|
advancedSearch?: AdvancedSearch
|
||||||
uuids?: string[]
|
uuids?: string[]
|
||||||
|
skipCount?: boolean
|
||||||
}): Observable<ResultList<Video>> {
|
}): Observable<ResultList<Video>> {
|
||||||
const { search, uuids, componentPagination, advancedSearch } = parameters
|
const { search, uuids, componentPagination, advancedSearch, skipCount } = parameters
|
||||||
|
|
||||||
if (advancedSearch?.resultType !== undefined && advancedSearch.resultType !== 'videos') {
|
if (advancedSearch?.resultType !== undefined && advancedSearch.resultType !== 'videos') {
|
||||||
return of({ total: 0, data: [] })
|
return of({ total: 0, data: [] })
|
||||||
|
@ -49,6 +50,7 @@ export class SearchService {
|
||||||
params = this.restService.addRestGetParams(params, pagination)
|
params = this.restService.addRestGetParams(params, pagination)
|
||||||
|
|
||||||
if (search) params = params.append('search', search)
|
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 (uuids) params = this.restService.addArrayParams(params, 'uuids', uuids)
|
||||||
|
|
||||||
if (advancedSearch) {
|
if (advancedSearch) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { Hooks } from '@server/lib/plugins/hooks.js'
|
||||||
import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search.js'
|
import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search.js'
|
||||||
import { getServerActor } from '@server/models/application/application.js'
|
import { getServerActor } from '@server/models/application/application.js'
|
||||||
import { HttpStatusCode, ResultList, Video, VideosSearchQueryAfterSanitize } from '@peertube/peertube-models'
|
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 { logger } from '../../../helpers/logger.js'
|
||||||
import { getFormattedObjects } from '../../../helpers/utils.js'
|
import { getFormattedObjects } from '../../../helpers/utils.js'
|
||||||
import {
|
import {
|
||||||
|
@ -61,7 +61,7 @@ function searchVideos (req: express.Request, res: express.Response) {
|
||||||
return searchVideosIndex(query, res)
|
return searchVideosIndex(query, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
return searchVideosDB(query, res)
|
return searchVideosDB(query, req, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function searchVideosIndex (query: VideosSearchQueryAfterSanitize, res: express.Response) {
|
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 serverActor = await getServerActor()
|
||||||
|
|
||||||
const apiOptions = await Hooks.wrapObject({
|
const apiOptions = await Hooks.wrapObject({
|
||||||
|
@ -112,6 +112,8 @@ async function searchVideosDB (query: VideosSearchQueryAfterSanitize, res: expre
|
||||||
orLocalVideos: true
|
orLocalVideos: true
|
||||||
},
|
},
|
||||||
|
|
||||||
|
countVideos: getCountVideos(req),
|
||||||
|
|
||||||
nsfw: buildNSFWFilter(res, query.nsfw),
|
nsfw: buildNSFWFilter(res, query.nsfw),
|
||||||
user: res.locals.oauth
|
user: res.locals.oauth
|
||||||
? res.locals.oauth.token.User
|
? res.locals.oauth.token.User
|
||||||
|
|
|
@ -1241,6 +1241,8 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
||||||
uuids?: string[]
|
uuids?: string[]
|
||||||
|
|
||||||
excludeAlreadyWatched?: boolean
|
excludeAlreadyWatched?: boolean
|
||||||
|
|
||||||
|
countVideos?: boolean
|
||||||
}) {
|
}) {
|
||||||
VideoModel.throwIfPrivateIncludeWithoutUser(options.include, options.user)
|
VideoModel.throwIfPrivateIncludeWithoutUser(options.include, options.user)
|
||||||
VideoModel.throwIfPrivacyOneOfWithoutUser(options.privacyOneOf, options.user)
|
VideoModel.throwIfPrivacyOneOfWithoutUser(options.privacyOneOf, options.user)
|
||||||
|
@ -1281,7 +1283,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
||||||
serverAccountIdForBlock: serverActor.Account.id
|
serverAccountIdForBlock: serverActor.Account.id
|
||||||
}
|
}
|
||||||
|
|
||||||
return VideoModel.getAvailableForApi(queryOptions)
|
return VideoModel.getAvailableForApi(queryOptions, options.countVideos)
|
||||||
}
|
}
|
||||||
|
|
||||||
static countLives (options: {
|
static countLives (options: {
|
||||||
|
|
Loading…
Reference in New Issue