From 83a774572ad8c69f379cd3032fc4b818b19b20f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A0=EB=B3=91=EC=B2=A0?= Date: Tue, 3 Mar 2026 18:48:15 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[today-issue]=20=EB=82=A0=EC=A7=9C=20?= =?UTF-8?q?=EA=B8=B0=EB=B0=98=20=EC=9D=B4=EC=A0=84=20=EC=9D=B4=EC=8A=88=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - TodayIssueController에 date 파라미터(YYYY-MM-DD) 추가 - TodayIssueService.summary()에 날짜 기반 필터링 로직 구현 - 이전 이슈 조회 시 만료(active) 필터 무시하여 과거 데이터 조회 가능 Co-Authored-By: Claude Opus 4.6 --- .../Api/V1/TodayIssueController.php | 5 ++-- app/Services/TodayIssueService.php | 24 ++++++++++++++----- package-lock.json | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Api/V1/TodayIssueController.php b/app/Http/Controllers/Api/V1/TodayIssueController.php index e25eff5..c510953 100644 --- a/app/Http/Controllers/Api/V1/TodayIssueController.php +++ b/app/Http/Controllers/Api/V1/TodayIssueController.php @@ -20,9 +20,10 @@ public function __construct( public function summary(Request $request): JsonResponse { $limit = (int) $request->input('limit', 30); + $date = $request->input('date'); // YYYY-MM-DD (이전 이슈 조회용) - return ApiResponse::handle(function () use ($limit) { - return $this->todayIssueService->summary($limit); + return ApiResponse::handle(function () use ($limit, $date) { + return $this->todayIssueService->summary($limit, null, $date); }, __('message.fetched')); } diff --git a/app/Services/TodayIssueService.php b/app/Services/TodayIssueService.php index 6a801fd..93f5139 100644 --- a/app/Services/TodayIssueService.php +++ b/app/Services/TodayIssueService.php @@ -17,30 +17,42 @@ class TodayIssueService extends Service * * @param int $limit 조회할 최대 항목 수 (기본 30) * @param string|null $badge 뱃지 필터 (null이면 전체) + * @param string|null $date 조회 날짜 (YYYY-MM-DD, null이면 오늘) */ - public function summary(int $limit = 30, ?string $badge = null): array + public function summary(int $limit = 30, ?string $badge = null, ?string $date = null): array { $tenantId = $this->tenantId(); $userId = $this->apiUserId(); + // date 파라미터가 있으면 해당 날짜, 없으면 오늘 + $targetDate = $date ? Carbon::parse($date) : today(); + $query = TodayIssue::query() ->where('tenant_id', $tenantId) ->forUser($userId) // 본인 대상 또는 전체 브로드캐스트 - ->active() // 만료되지 않은 이슈만 - ->today() // 오늘 날짜 이슈만 + ->whereDate('created_at', $targetDate) ->orderByDesc('created_at'); + // 이전 이슈 조회 시에는 만료 필터 무시 (과거 데이터도 조회 가능) + if (! $date) { + $query->active(); // 오늘 이슈만 만료 필터 적용 + } + // 뱃지 필터 if ($badge !== null && $badge !== 'all') { $query->byBadge($badge); } - // 전체 개수 (필터 적용 전, 오늘 날짜만) + // 전체 개수 (필터 적용 전) $totalQuery = TodayIssue::query() ->where('tenant_id', $tenantId) ->forUser($userId) - ->active() - ->today(); + ->whereDate('created_at', $targetDate); + + if (! $date) { + $totalQuery->active(); + } + $totalCount = $totalQuery->count(); // 결과 조회 diff --git a/package-lock.json b/package-lock.json index 6898565..bb18a55 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "api", + "name": "sam-api", "lockfileVersion": 3, "requires": true, "packages": {