feat: [today-issue] 날짜 기반 이전 이슈 조회 기능 추가
- TodayIssueController에 date 파라미터(YYYY-MM-DD) 추가 - TodayIssueService.summary()에 날짜 기반 필터링 로직 구현 - 이전 이슈 조회 시 만료(active) 필터 무시하여 과거 데이터 조회 가능 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
// 결과 조회
|
||||
|
||||
Reference in New Issue
Block a user