Skip to content

Commit af78a70

Browse files
committed
refactor: weekly method in StatsService for stats message
1 parent a87c50e commit af78a70

File tree

1 file changed

+7
-5
lines changed
  • packages/velog-cron/src/services/StatsService

1 file changed

+7
-5
lines changed

packages/velog-cron/src/services/StatsService/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,19 @@ export class StatsService implements Service {
4343
)
4444
}
4545
public async weekly() {
46-
const start = startOfWeek(subWeeks(new Date(), 1), { weekStartsOn: 1 }) // 월요일부터 시작
47-
const end = endOfWeek(subWeeks(new Date(), 1))
46+
const oneWeekAgo = subWeeks(new Date(), 1)
47+
const start = startOfWeek(oneWeekAgo, { weekStartsOn: 1 }) // 월요일부터 시작
48+
const end = endOfWeek(oneWeekAgo, { weekStartsOn: 1 })
4849

4950
const usersCount = await this.getUsersCount(start, end)
5051
const postCount = await this.getPostsCount(start, end)
5152

53+
const timeFormat = 'yyyy-MM-dd HH:mm:ss'
5254
await this.discord.sendMessage(
5355
'stats',
54-
`[Weekly]\n기간: ${format(
55-
start,
56-
'yyyy-MM-dd',
56+
`[Daily]\n기간: ${format(start, timeFormat)}-${format(
57+
end,
58+
'HH:mm:ss',
5759
)}\n${usersCount}명의 사용자가 가입했습니다.\n${postCount}개의 공개 포스트가 작성되었습니다.`,
5860
)
5961
}

0 commit comments

Comments
 (0)