Skip to content

Commit

Permalink
Feat: 캐러셀에 들어가는 웨일비 데이터는 모집기간이 남아있는 데이터 최대 7개로 제한
Browse files Browse the repository at this point in the history
  • Loading branch information
pp449 committed Sep 24, 2023
1 parent e07046c commit d5979d6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/apis/notice/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ export const getWhalebe = async (): Promise<WhalebeData[]> => {
return new Promise<WhalebeData[]>((resolve) => {
db.query(query, (err, res) => {
if (err) notificationToSlack('웨일비 조회 실패');
resolve(res as WhalebeData[]);
const whalebeData = res as WhalebeData[];
const today = new Date();
const todayString = `${today.getFullYear()}-${String(
today.getMonth() + 1,
).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;

const filteredData = whalebeData
.filter((data) => data.date >= todayString)
.slice(0, 7);
resolve(filteredData);
});
});
};

0 comments on commit d5979d6

Please sign in to comment.