Skip to content

Commit

Permalink
🐛 fix: RANK 값 안넘어가는 문제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kms0219kms committed Sep 26, 2024
1 parent e967b72 commit 6204adb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/charts/charts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class ChartsService {

return {
...music,
rank: chart?.[type] || { views: 0, rank: 'NEW' },
rank: chart?.[type] || { views: 0, rank: -1 },
};
})
.sort((a, b) => b.rank.views - a.rank.views),
Expand Down
6 changes: 3 additions & 3 deletions src/charts/dto/chart.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class ChartData extends musicDetailDto {
views: number;

/**
* 조회수 증감량
* @example NEW
* 조회수 증감량 (-1: NEW)
* @example -1
*/
rank: number | 'NEW';
rank: number;
};
}

Expand Down
27 changes: 18 additions & 9 deletions src/common/repository/schemas/statistics.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@ export interface IStatistics {
}

export type IStatisticData = {
/**
* 현재 조회수 값
* @example 1
*/
views: number;
rank: number | 'NEW';

/**
* 조회수 증감량
* @example -1
*/
rank: number;
};

export const StatisticsSchema = new mongoose.Schema<IStatistics>({
Expand All @@ -26,9 +35,9 @@ export const StatisticsSchema = new mongoose.Schema<IStatistics>({
default: 0,
},
rank: {
type: Number || String,
type: Number,
required: true,
default: 'NEW',
default: -1,
},
},
daily: {
Expand All @@ -38,9 +47,9 @@ export const StatisticsSchema = new mongoose.Schema<IStatistics>({
default: 0,
},
rank: {
type: Number || String,
type: Number,
required: true,
default: 'NEW',
default: -1,
},
},
total: {
Expand All @@ -50,9 +59,9 @@ export const StatisticsSchema = new mongoose.Schema<IStatistics>({
default: 0,
},
rank: {
type: Number || String,
type: Number,
required: true,
default: 'NEW',
default: -1,
},
},
weekly: {
Expand All @@ -62,9 +71,9 @@ export const StatisticsSchema = new mongoose.Schema<IStatistics>({
default: 0,
},
rank: {
type: Number || String,
type: Number,
required: true,
default: 'NEW',
default: -1,
},
},
});
13 changes: 11 additions & 2 deletions src/songs/dto/music.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,17 @@ export class musicDetailDto extends musicDto {

export interface IMusicChart extends musicDetailDto {
rank: {
current: number;
increase: number | string;
/**
* 현재 조회수 값
* @example 1
*/
views: number;

/**
* 조회수 증감량
* @example -1
*/
rank: number;
};
}

Expand Down

0 comments on commit 6204adb

Please sign in to comment.