Skip to content

Commit

Permalink
fix : 유저가 업로드한 영상 응답 시 업로드가 매긴 별점으로 응답되던 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
msjang4 committed Dec 13, 2023
1 parent eb96adf commit 6292eb4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion server/src/action/action.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ActionController {
@RequestUser() user: User,
@Query() query: SeedQueryDto,
) {
console.log(`조회수 증가 API : ${JSON.stringify(query)}`);
console.log(`${user.id} 조회수 증가 API : ${JSON.stringify(query)}`);
return this.actionService.viewVideo(videoId, user.id, query.seed);
}
}
2 changes: 2 additions & 0 deletions server/src/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ export class UserController {
getUploadedVideos(
@Param('userId') userId: string,
@Query() query: UserUploadedVideoQueryDto,
@RequestUser() user: User,
) {
return this.userService.getUploadedVideos(
userId,
user.id,
query.limit,
query.lastId,
);
Expand Down
17 changes: 13 additions & 4 deletions server/src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ export class UserService {
};
}

async getUploadedVideos(uuid: string, limit: number, lastId: string) {
async getUploadedVideos(
uuid: string,
viewerUuid: string,
limit: number,
lastId: string,
) {
const uploaderData = await this.UserModel.findOne({ uuid }, { actions: 0 });
if (!uploaderData) {
throw new UserNotFoundException();
Expand All @@ -116,7 +121,7 @@ export class UserService {
.sort({ _id: -1 })
.limit(limit);

const videos = await this.getVideoInfos(videoData, uploader, uuid);
const videos = await this.getVideoInfos(videoData, uploader, viewerUuid);
return { videos };
}

Expand All @@ -140,7 +145,11 @@ export class UserService {
return { uploader, uploaderId };
}

async getVideoInfos(videoData: Array<any>, uploader: object, uuid: string) {
async getVideoInfos(
videoData: Array<any>,
uploader: object,
viewerUuid: string,
) {
const videos = await Promise.all(
videoData.map(async (video) => {
const { thumbnailExtension, raterCount, totalRating, ...videoInfo } =
Expand All @@ -149,7 +158,7 @@ export class UserService {
? (totalRating / raterCount).toFixed(1)
: null;
const userRating = await this.videoService.getUserRating(
uuid,
viewerUuid,
videoInfo._id,
);
const manifest = `${process.env.MANIFEST_URL_PREFIX}/${videoInfo._id}_master.m3u8`;
Expand Down
2 changes: 1 addition & 1 deletion server/src/video/video.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class VideoController {
@Query() query: RandomVideoQueryDto,
@RequestUser() user: User,
) {
console.log(`랜덤 비디오 응답 API : ${JSON.stringify(query)}`);
console.log(`${user.id} 랜덤 비디오 응답 API : ${JSON.stringify(query)}`);
return this.videoService.getRandomVideo(query, user.id);
}

Expand Down
1 change: 0 additions & 1 deletion server/src/video/video.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export class VideoService {
{ category, limit, seed }: RandomVideoQueryDto,
userId: string,
) {
console.log('random video response:', category, limit, seed);
const actions = await this.UserModel.aggregate([
{ $match: { uuid: userId } },
{ $unwind: '$actions' },
Expand Down

0 comments on commit 6292eb4

Please sign in to comment.