Add create date on history items
This commit is contained in:
@@ -1,4 +1,15 @@
|
||||
import { Body, Controller, DefaultValuePipe, Get, HttpCode, ParseIntPipe, Post, Query, Request, UseGuards } from '@nestjs/common';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
DefaultValuePipe,
|
||||
Get,
|
||||
HttpCode,
|
||||
ParseIntPipe,
|
||||
Post,
|
||||
Query,
|
||||
Request,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags, ApiUnauthorizedResponse } from '@nestjs/swagger';
|
||||
import { SearchHistory, SongHistory } from '@prisma/client';
|
||||
import { JwtAuthGuard } from 'src/auth/jwt-auth.guard';
|
||||
@@ -6,9 +17,9 @@ import { SongHistoryDto } from './dto/SongHistoryDto';
|
||||
import { HistoryService } from './history.service';
|
||||
|
||||
@Controller('history')
|
||||
@ApiTags("history")
|
||||
@ApiTags('history')
|
||||
export class HistoryController {
|
||||
constructor(private readonly historyService: HistoryService) {}
|
||||
constructor(private readonly historyService: HistoryService) { }
|
||||
|
||||
@Get()
|
||||
@HttpCode(200)
|
||||
@@ -22,7 +33,7 @@ export class HistoryController {
|
||||
return this.historyService.getHistory(req.user.id, { skip, take });
|
||||
}
|
||||
|
||||
@Get("search")
|
||||
@Get('search')
|
||||
@HttpCode(200)
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiUnauthorizedResponse({ description: 'Invalid token' })
|
||||
|
||||
@@ -6,7 +6,7 @@ import { SongHistoryDto } from './dto/SongHistoryDto';
|
||||
|
||||
@Injectable()
|
||||
export class HistoryService {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
constructor(private prisma: PrismaService) { }
|
||||
|
||||
async createSongHistoryRecord({
|
||||
songID,
|
||||
@@ -46,6 +46,7 @@ export class HistoryService {
|
||||
): Promise<SongHistory[]> {
|
||||
return this.prisma.songHistory.findMany({
|
||||
where: { user: { id: playerId } },
|
||||
orderBy: { playDate: 'asc' },
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
@@ -75,6 +76,7 @@ export class HistoryService {
|
||||
): Promise<SearchHistory[]> {
|
||||
return this.prisma.searchHistory.findMany({
|
||||
where: { user: { id: playerId } },
|
||||
orderBy: { searchDate: 'asc' },
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user