mirror of https://github.com/Chocobozzz/PeerTube
Improve recommended videos without video tags
parent
4f8b623668
commit
8ece9c8ca0
|
@ -39,22 +39,21 @@ export class RecentVideosRecommendationService implements RecommendationService
|
||||||
|
|
||||||
private fetchPage (page: number, recommendation: RecommendationInfo): Observable<Video[]> {
|
private fetchPage (page: number, recommendation: RecommendationInfo): Observable<Video[]> {
|
||||||
const pagination = { currentPage: page, itemsPerPage: this.pageSize + 1 }
|
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()
|
return this.userService.getAnonymousOrLoggedUser()
|
||||||
.pipe(
|
.pipe(
|
||||||
map(user => {
|
switchMap(user => {
|
||||||
return {
|
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: '',
|
search: '',
|
||||||
componentPagination: pagination,
|
componentPagination: pagination,
|
||||||
advancedSearch: new AdvancedSearch({
|
advancedSearch: new AdvancedSearch({
|
||||||
|
@ -68,14 +67,15 @@ export class RecentVideosRecommendationService implements RecommendationService
|
||||||
? true
|
? true
|
||||||
: undefined
|
: undefined
|
||||||
})
|
})
|
||||||
}
|
})
|
||||||
}),
|
.pipe(
|
||||||
switchMap(params => this.searchService.searchVideos(params)),
|
map(v => v.data),
|
||||||
map(v => v.data),
|
switchMap(videos => {
|
||||||
switchMap(videos => {
|
if (videos.length <= 1) return defaultSubscription
|
||||||
if (videos.length <= 1) return defaultSubscription
|
|
||||||
|
|
||||||
return of(videos)
|
return of(videos)
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue