Skip to content

Commit

Permalink
fix: 날짜 형식 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
sjy2335 committed Nov 28, 2024
1 parent 674901e commit a241351
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions backend/name-server/src/database/query/dau-recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ export class DAURecorder implements DAURecorderInterface {
private clickhouseClient = ClickhouseDatabase.getInstance();

public async recordAccess(domain: string): Promise<void> {
const dateString = new Date().toLocaleDateString();
const values = [{ domain: domain.toLowerCase(), date: dateString, access: 1 }];
const values = [
{ domain: domain.toLowerCase(), date: this.formatDate(new Date()), access: 1 },
];
try {
await this.clickhouseClient.insert({
table: 'dau',
Expand All @@ -20,4 +21,12 @@ export class DAURecorder implements DAURecorderInterface {
console.error('ClickHouse Error:', error);
}
}

private formatDate(date: Date): string {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');

return `${year}-${month}-${day}`;
}
}

0 comments on commit a241351

Please sign in to comment.