2020-05-09 19:22:17 +02:00
|
|
|
import { Controller, Get, Query } from "@nestjs/common";
|
|
|
|
|
import { Auth } from "src/auth/decorators/auth.decorator";
|
|
|
|
|
import { ReqUser } from "../auth/decorators/req-user.decorator";
|
|
|
|
|
import { User } from "../users/user.entity";
|
|
|
|
|
import { GetListenReportDto } from "./dto/get-listen-report.dto";
|
2020-05-31 23:26:06 +02:00
|
|
|
import { GetTopArtistsReportDto } from "./dto/get-top-artists-report.dto";
|
2020-05-09 19:22:17 +02:00
|
|
|
import { ListenReportDto } from "./dto/listen-report.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";
|
|
|
|
|
|
|
|
|
|
@Controller("api/v1/reports")
|
|
|
|
|
export class ReportsController {
|
|
|
|
|
constructor(private readonly reportsService: ReportsService) {}
|
|
|
|
|
|
|
|
|
|
@Get("listens")
|
|
|
|
|
@Auth()
|
|
|
|
|
async getListens(
|
2020-06-01 20:19:44 +02:00
|
|
|
@Query() options: GetListenReportDto,
|
2020-05-09 19:22:17 +02:00
|
|
|
@ReqUser() user: User
|
|
|
|
|
): Promise<ListenReportDto> {
|
|
|
|
|
return this.reportsService.getListens({ ...options, user });
|
|
|
|
|
}
|
2020-05-31 23:26:06 +02:00
|
|
|
|
|
|
|
|
@Get("top-artists")
|
|
|
|
|
@Auth()
|
|
|
|
|
async getTopArtists(
|
|
|
|
|
@Query() options: Omit<GetTopArtistsReportDto, "user">,
|
|
|
|
|
@ReqUser() user: User
|
|
|
|
|
): Promise<TopArtistsReportDto> {
|
|
|
|
|
return this.reportsService.getTopArtists({ ...options, user });
|
|
|
|
|
}
|
2020-05-09 19:22:17 +02:00
|
|
|
}
|