File size: 1,578 Bytes
b0798af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Controller, Get, Param, UseGuards, Req } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { RecommendationsService } from './recommendations.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';

@ApiTags('Recommendation Engine')
@Controller('me/recommendations')
export class RecommendationsController {
  constructor(private readonly recsService: RecommendationsService) {}

  @Get('home')
  @UseGuards(JwtAuthGuard)
  @ApiBearerAuth()
  @ApiOperation({
    summary: 'Home feed shelves: Recently Played, Made For You, Popular Albums',
  })
  getHomeShelves(@Req() req: any) {
    return this.recsService.getHomeShelves(req.user.userId);
  }

  @Get('discover-weekly')
  @UseGuards(JwtAuthGuard)
  @ApiBearerAuth()
  @ApiOperation({
    summary: 'Weekly personalized mix generated via pgvector similarity',
  })
  getDiscoverWeekly(@Req() req: any) {
    return this.recsService.getDiscoverWeekly(req.user.userId);
  }

  @Get('tracks/:id/related')
  @ApiOperation({ summary: 'Related tracks (Fans also like) via pgvector' })
  getRelatedTracks(@Param('id') id: string) {
    return this.recsService.getRelatedTracks(id);
  }

  @Get('radio/:seedType/:seedId')
  @UseGuards(JwtAuthGuard)
  @ApiBearerAuth()
  @ApiOperation({
    summary: 'Infinite radio queue seeded from a track, artist, or playlist',
  })
  getRadio(
    @Req() req: any,
    @Param('seedType') seedType: string,
    @Param('seedId') seedId: string,
  ) {
    return this.recsService.getRadio(req.user.userId, seedType, seedId);
  }
}