Skip to content

Commit

Permalink
Merge pull request #111 from GDSC-PKNU-21-22/fix/#110
Browse files Browse the repository at this point in the history
Feat: 캐러셀에 들어가는 웨일비 데이터는 모집기간이 남아있는 데이터 최대 7개로 제한
  • Loading branch information
pp449 authored Sep 26, 2023
2 parents 11b6f99 + d5979d6 commit 504d232
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 504d232

Please sign in to comment.