-
Notifications
You must be signed in to change notification settings - Fork 0
Feature / admin / dashboard #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ef8780d
feat(admin): implement admin dashboard stats endpoint with member and…
eraser502 32d0421
feat(admin): update admin dashboard stats to include pending consulta…
eraser502 02bfe61
feat(admin): adjust timezone for admin dashboard stats to Asia/Seoul
eraser502 37871a4
feat(admin): add index on created_at column for redot_members table
eraser502 4f18f67
feat(admin): refactor dashboard stats to use ZonedDateTime for accura…
eraser502 d2d89ab
feat(admin): refactor dashboard stats to use LocalDateTime for improv…
eraser502 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/main/java/redot/redot_server/domain/admin/controller/AdminDashboardController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package redot.redot_server.domain.admin.controller; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
| import redot.redot_server.domain.admin.controller.docs.AdminDashboardControllerDocs; | ||
| import redot.redot_server.domain.admin.dto.response.AdminDashboardStatsResponse; | ||
| import redot.redot_server.domain.admin.service.AdminDashboardService; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/v1/redot/admin/dashboard") | ||
| @RequiredArgsConstructor | ||
| public class AdminDashboardController implements AdminDashboardControllerDocs { | ||
|
|
||
| private final AdminDashboardService adminDashboardService; | ||
|
|
||
| @GetMapping("/stats") | ||
| @Override | ||
| public ResponseEntity<AdminDashboardStatsResponse> getDashboardStats() { | ||
| return ResponseEntity.ok(adminDashboardService.getDashboardStats()); | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
...in/java/redot/redot_server/domain/admin/controller/docs/AdminDashboardControllerDocs.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package redot.redot_server.domain.admin.controller.docs; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.media.Content; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import org.springframework.http.ResponseEntity; | ||
| import redot.redot_server.domain.admin.dto.response.AdminDashboardStatsResponse; | ||
|
|
||
| @Tag(name = "Admin Dashboard", description = "관리자 대시보드 통계 API") | ||
| public interface AdminDashboardControllerDocs { | ||
|
|
||
| @Operation(summary = "대시보드 통계 조회", description = "관리자 대시보드에 필요한 요약 통계를 제공합니다.") | ||
| @ApiResponse(responseCode = "200", description = "조회 성공", | ||
| content = @Content(schema = @Schema(implementation = AdminDashboardStatsResponse.class))) | ||
| ResponseEntity<AdminDashboardStatsResponse> getDashboardStats(); | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/redot/redot_server/domain/admin/dto/response/AdminDashboardStatsResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package redot.redot_server.domain.admin.dto.response; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| public record AdminDashboardStatsResponse( | ||
| @Schema(description = "전체 Redot 회원 수") long totalRedotMembers, | ||
| @Schema(description = "전일까지 누적된 Redot 회원 수") long redotMembersUntilYesterday, | ||
| @Schema(description = "상태가 PENDING 인 상담 요청 수") long pendingConsultationCount, | ||
| @Schema(description = "등록된 관리자 수") long adminCount | ||
| ) { | ||
| } |
45 changes: 45 additions & 0 deletions
45
src/main/java/redot/redot_server/domain/admin/service/AdminDashboardService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package redot.redot_server.domain.admin.service; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import java.time.ZoneId; | ||
| import java.time.ZoneOffset; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
| import redot.redot_server.domain.admin.dto.response.AdminDashboardStatsResponse; | ||
| import redot.redot_server.domain.admin.repository.AdminRepository; | ||
| import redot.redot_server.domain.redot.consultation.entity.ConsultationStatus; | ||
| import redot.redot_server.domain.redot.consultation.repository.ConsultationRepository; | ||
| import redot.redot_server.domain.redot.member.repository.RedotMemberRepository; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| public class AdminDashboardService { | ||
|
|
||
| private final RedotMemberRepository redotMemberRepository; | ||
| private final ConsultationRepository consultationRepository; | ||
| private final AdminRepository adminRepository; | ||
|
|
||
| public AdminDashboardStatsResponse getDashboardStats() { | ||
| ZoneId kstZone = ZoneId.of("Asia/Seoul"); | ||
| LocalDateTime startOfTodayKst = LocalDate.now(kstZone).atStartOfDay(); | ||
| LocalDateTime startOfTodayUtc = startOfTodayKst.atZone(kstZone) | ||
| .withZoneSameInstant(ZoneOffset.UTC) | ||
| .toLocalDateTime(); | ||
|
|
||
| long totalRedotMembers = redotMemberRepository.count(); | ||
| long redotMembersUntilYesterday = redotMemberRepository.countByCreatedAtBefore(startOfTodayUtc); | ||
|
|
||
| long pendingConsultationCount = consultationRepository.countByStatus(ConsultationStatus.PENDING); | ||
| long adminCount = adminRepository.count(); | ||
|
|
||
| return new AdminDashboardStatsResponse( | ||
| totalRedotMembers, | ||
| redotMembersUntilYesterday, | ||
| pendingConsultationCount, | ||
| adminCount | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/resources/db/migration/V7__add_index_to_redot_members_created_at.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| CREATE INDEX IF NOT EXISTS idx_redot_members_created_at ON redot_members(created_at); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.