1 import { Inject, Injectable } from '@angular/core'
2 import { RecommendationService } from '@app/videos/recommendations/recommendations.service'
3 import { Video } from '@app/shared/video/video.model'
4 import { VideoService, VideosProvider } from '@app/shared/video/video.service'
5 import { map } from 'rxjs/operators'
6 import { Observable } from 'rxjs'
9 * Provides "recommendations" by providing the most recently uploaded videos.
12 export class RecentVideosRecommendationService implements RecommendationService {
17 @Inject(VideoService) private videos: VideosProvider
21 getRecommendations (uuid: string): Observable<Video[]> {
22 return this.fetchPage(1)
25 const otherVideos = vids.filter(v => v.uuid !== uuid)
26 return otherVideos.slice(0, this.pageSize)
31 private fetchPage (page: number): Observable<Video[]> {
32 let pagination = { currentPage: page, itemsPerPage: this.pageSize + 1 }
33 return this.videos.getVideos(pagination, '-createdAt')