Skip to content

Commit 083e7d9

Browse files
committed
feat: Count 집계 기능 구현
1 parent 1ff0f08 commit 083e7d9

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

services/plans/planManageService.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
writeBatch,
1313
} from 'firebase/firestore';
1414
import { db } from '@/lib/firebase';
15+
import { bumpDailyStat } from '@/services/heatmap/dailyStat.service';
1516

1617
// 플랜 데이터 타입
1718
export interface Plan {
@@ -111,6 +112,8 @@ export const toggleItemStatus = async (
111112
await updateDoc(itemRef, {
112113
isChecked: !currentStatus,
113114
});
115+
const delta = !currentStatus ? 1 : -1;
116+
await bumpDailyStat(uid, 0, delta);
114117
};
115118

116119
// 6. 플랜 삭제

services/write/til.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
Timestamp,
1010
} from 'firebase/firestore';
1111
import { db } from '@/lib/firebase';
12+
import { bumpDailyStat } from '@/services/heatmap/dailyStat.service';
1213

1314
export type TilData = {
1415
title: string;
@@ -27,6 +28,7 @@ export async function createTil(uid: string, content: string, title: string) {
2728
createdAt: serverTimestamp(),
2829
updatedAt: serverTimestamp(),
2930
});
31+
await bumpDailyStat(uid, 1, 0);
3032
return docRef.id;
3133
}
3234

0 commit comments

Comments
 (0)