Skip to content

Commit 50a9c70

Browse files
committed
refactor: improve formatting and update play count logic in getSong method
1 parent 483c007 commit 50a9c70

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

server/src/song/song.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ export class SongService {
260260
publicId: string,
261261
user: UserDocument | null,
262262
): Promise<SongViewDto> {
263-
const foundSong = await this.songModel.findOne({ publicId: publicId });
263+
const foundSong = await this.songModel.findOne({
264+
publicId: publicId,
265+
});
264266

265267
if (!foundSong) {
266268
throw new HttpException('Song not found', HttpStatus.NOT_FOUND);
@@ -278,7 +280,11 @@ export class SongService {
278280

279281
// increment view count
280282
foundSong.playCount++;
281-
await foundSong.save();
283+
284+
this.songModel.updateOne(
285+
{ publicId: publicId },
286+
{ playCount: foundSong.playCount },
287+
);
282288

283289
const populatedSong = await foundSong.populate(
284290
'uploader',

0 commit comments

Comments
 (0)