Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

유저가 업로드한 영상 응답 버그 수정 #281

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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