Improve recommended videos without video tags

This commit is contained in:
Chocobozzz 2023-07-19 13:24:31 +02:00
parent 4f8b623668
commit 8ece9c8ca0
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 20 additions and 20 deletions

View File

@ -39,22 +39,21 @@ export class RecentVideosRecommendationService implements RecommendationService
private fetchPage (page: number, recommendation: RecommendationInfo): Observable<Video[]> {
const pagination = { currentPage: page, itemsPerPage: this.pageSize + 1 }
const defaultSubscription = this.videos.getVideos({ videoPagination: pagination, sort: '-createdAt' })
.pipe(map(v => v.data))
const tags = recommendation.tags
const searchIndexConfig = this.config.search.searchIndex
if (
!tags || tags.length === 0 ||
(searchIndexConfig.enabled === true && searchIndexConfig.disableLocalSearch === true)
) {
return defaultSubscription
}
return this.userService.getAnonymousOrLoggedUser()
.pipe(
map(user => {
return {
switchMap(user => {
const defaultSubscription = this.videos.getVideos({
videoPagination: pagination,
sort: '-publishedAt'
}).pipe(map(v => v.data))
const searchIndexConfig = this.config.search.searchIndex
if (searchIndexConfig.enabled === true && searchIndexConfig.disableLocalSearch === true) {
return defaultSubscription
}
return this.searchService.searchVideos({
search: '',
componentPagination: pagination,
advancedSearch: new AdvancedSearch({
@ -68,9 +67,8 @@ export class RecentVideosRecommendationService implements RecommendationService
? true
: undefined
})
}
}),
switchMap(params => this.searchService.searchVideos(params)),
})
.pipe(
map(v => v.data),
switchMap(videos => {
if (videos.length <= 1) return defaultSubscription
@ -78,5 +76,7 @@ export class RecentVideosRecommendationService implements RecommendationService
return of(videos)
})
)
})
)
}
}