2020-05-09 19:22:17 +02:00
|
|
|
import { Controller, Get, Query } from "@nestjs/common";
|
2020-09-05 21:07:05 +02:00
|
|
|
import { Auth } from "../auth/decorators/auth.decorator";
|
2020-05-09 19:22:17 +02:00
|
|
|
import { ReqUser } from "../auth/decorators/req-user.decorator";
|
|
|
|
|
import { User } from "../users/user.entity";
|
|
|
|
|
import { ListenReportDto } from "./dto/listen-report.dto";
|
2020-07-12 17:17:50 +02:00
|
|
|
import { ReportTimeDto } from "./dto/report-time.dto";
|
2020-05-31 23:26:06 +02:00
|
|
|
import { TopArtistsReportDto } from "./dto/top-artists-report.dto";
|
2020-05-09 19:22:17 +02:00
|
|
|
import { ReportsService } from "./reports.service";
|
2020-07-12 17:17:50 +02:00
|
|
|
import { Timeframe } from "./timeframe.enum";
|
2020-05-09 19:22:17 +02:00
|
|
|
|
|
|
|
|
@Controller("api/v1/reports")
|
|
|
|
|
export class ReportsController {
|
|
|
|
|
constructor(private readonly reportsService: ReportsService) {}
|
|
|
|
|
|
|
|
|
|
@Get("listens")
|
|
|
|
|
@Auth()
|
|
|
|
|
async getListens(
|
2020-07-12 17:17:50 +02:00
|
|
|
@Query() time: ReportTimeDto,
|
|
|
|
|
@Query("timeFrame") timeFrame: Timeframe,
|
2020-05-09 19:22:17 +02:00
|
|
|
@ReqUser() user: User
|
|
|
|
|
): Promise<ListenReportDto> {
|
2020-07-12 17:17:50 +02:00
|
|
|
return this.reportsService.getListens({ user, timeFrame, time });
|
2020-05-09 19:22:17 +02:00
|
|
|
}
|
2020-05-31 23:26:06 +02:00
|
|
|
|
|
|
|
|
@Get("top-artists")
|
|
|
|
|
@Auth()
|
|
|
|
|
async getTopArtists(
|
2020-07-12 17:16:33 +02:00
|
|
|
@Query() time: ReportTimeDto,
|
2020-05-31 23:26:06 +02:00
|
|
|
@ReqUser() user: User
|
|
|
|
|
): Promise<TopArtistsReportDto> {
|
2020-07-12 17:16:33 +02:00
|
|
|
return this.reportsService.getTopArtists({ user, time });
|
2020-05-31 23:26:06 +02:00
|
|
|
}
|
2020-05-09 19:22:17 +02:00
|
|
|
}
|