Skip to content
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

refactor#112 어드민용 기수순 유저 조회 추가 #113

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jj0526
Copy link
Collaborator

@jj0526 jj0526 commented Jan 22, 2025

PR 내용

  • 어드민용 기수순 유저 조회를 추가하였습니다

PR 세부사항

  • AdminResponse 객체들의 기수의 최대값을 이용해 정렬을 하였는데 더 좋은 정렬 방법이 있을까요?
  • 조회 시간은 94ms 나왔습니다

관련 스크린샷

다음은 28명의 유저를 기수순으로 조회한 결과입니다.
베이스는 status를 사용했습니다

{
    "code": 200,
    "message": "모든 회원 정보를 성공적으로 조회했습니다.",
    "data": [
        {
            "id": 1,
            "name": "admin",
            "email": "[email protected]",
            "studentId": "987654321",
            "tel": "01012345678",
            "department": "소프트웨어전공",
            "cardinals": [
                4
            ],
            "position": "BE",
            "status": "ACTIVE",
            "role": "ADMIN",
            "attendanceCount": 0,
            "absenceCount": 0,
            "attendanceRate": 0,
            "penaltyCount": 0,
            "createdAt": "2025-01-22T00:48:05",
            "modifiedAt": "2025-01-22T00:48:05"
        },
        {
            "id": 7,
            "name": "Eve",
            "email": "[email protected]",
            "studentId": "2025005",
            "tel": "01055556666",
            "department": "경영학과",
            "cardinals": [
                2,
                4
            ],
            "position": "FE",
            "status": "ACTIVE",
            "role": "USER",
            "attendanceCount": 9,
            "absenceCount": 1,
            "attendanceRate": 90,
            "penaltyCount": 1,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 18,
            "name": "Paul",
            "email": "[email protected]",
            "studentId": "2025016",
            "tel": "01066667777",
            "department": "인공지능전공",
            "cardinals": [
                4
            ],
            "position": "BE",
            "status": "WAITING",
            "role": "USER",
            "attendanceCount": 7,
            "absenceCount": 3,
            "attendanceRate": 70,
            "penaltyCount": 2,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 19,
            "name": "Quinn",
            "email": "[email protected]",
            "studentId": "2025017",
            "tel": "01077778888",
            "department": "컴퓨터공학과",
            "cardinals": [
                1,
                4
            ],
            "position": "FE",
            "status": "WAITING",
            "role": "USER",
            "attendanceCount": 6,
            "absenceCount": 4,
            "attendanceRate": 60,
            "penaltyCount": 3,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 27,
            "name": "Yara",
            "email": "[email protected]",
            "studentId": "2025025",
            "tel": "01055556666",
            "department": "경제학과",
            "cardinals": [
                3,
                4
            ],
            "position": "FE",
            "status": "WAITING",
            "role": "USER",
            "attendanceCount": 7,
            "absenceCount": 3,
            "attendanceRate": 70,
            "penaltyCount": 3,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 15,
            "name": "Mia",
            "email": "[email protected]",
            "studentId": "2025013",
            "tel": "01033334444",
            "department": "산업공학과",
            "cardinals": [
                4,
                3
            ],
            "position": "BE",
            "status": "LEFT",
            "role": "USER",
            "attendanceCount": 5,
            "absenceCount": 5,
            "attendanceRate": 50,
            "penaltyCount": 5,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 16,
            "name": "Noah",
            "email": "[email protected]",
            "studentId": "2025014",
            "tel": "01044445555",
            "department": "시각디자인학과",
            "cardinals": [
                4
            ],
            "position": "FE",
            "status": "LEFT",
            "role": "ADMIN",
            "attendanceCount": 7,
            "absenceCount": 7,
            "attendanceRate": 70,
            "penaltyCount": 3,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 17,
            "name": "Olivia",
            "email": "[email protected]",
            "studentId": "2025015",
            "tel": "01055556666",
            "department": "소프트웨어전공",
            "cardinals": [
                4
            ],
            "position": "D",
            "status": "LEFT",
            "role": "USER",
            "attendanceCount": 6,
            "absenceCount": 2,
            "attendanceRate": 75,
            "penaltyCount": 1,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 3,
            "name": "Alice",
            "email": "[email protected]",
            "studentId": "2025001",
            "tel": "01011112222",
            "department": "소프트웨어전공",
            "cardinals": [
                1,
                3
            ],
            "position": "BE",
            "status": "ACTIVE",
            "role": "USER",
            "attendanceCount": 10,
            "absenceCount": 0,
            "attendanceRate": 100,
            "penaltyCount": 0,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 23,
            "name": "Uma",
            "email": "[email protected]",
            "studentId": "2025021",
            "tel": "01011112222",
            "department": "시각디자인학과",
            "cardinals": [
                2,
                3
            ],
            "position": "BE",
            "status": "ACTIVE",
            "role": "USER",
            "attendanceCount": 10,
            "absenceCount": 0,
            "attendanceRate": 100,
            "penaltyCount": 0,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 28,
            "name": "Zara",
            "email": "[email protected]",
            "studentId": "2025026",
            "tel": "01066667777",
            "department": "경영학과",
            "cardinals": [
                3
            ],
            "position": "D",
            "status": "ACTIVE",
            "role": "ADMIN",
            "attendanceCount": 6,
            "absenceCount": 4,
            "attendanceRate": 60,
            "penaltyCount": 4,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 13,
            "name": "Kate",
            "email": "[email protected]",
            "studentId": "2025011",
            "tel": "01011112222",
            "department": "경제학과",
            "cardinals": [
                3
            ],
            "position": "FE",
            "status": "LEFT",
            "role": "USER",
            "attendanceCount": 0,
            "absenceCount": 10,
            "attendanceRate": 0,
            "penaltyCount": 10,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 14,
            "name": "Liam",
            "email": "[email protected]",
            "studentId": "2025012",
            "tel": "01022223333",
            "department": "경영학과",
            "cardinals": [
                3
            ],
            "position": "D",
            "status": "LEFT",
            "role": "USER",
            "attendanceCount": 5,
            "absenceCount": 0,
            "attendanceRate": 50,
            "penaltyCount": 0,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 11,
            "name": "Ivy",
            "email": "[email protected]",
            "studentId": "2025009",
            "tel": "01099990000",
            "department": "인공지능전공",
            "cardinals": [
                3,
                2
            ],
            "position": "D",
            "status": "BANNED",
            "role": "ADMIN",
            "attendanceCount": 2,
            "absenceCount": 8,
            "attendanceRate": 20,
            "penaltyCount": 8,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 12,
            "name": "Jack",
            "email": "[email protected]",
            "studentId": "2025010",
            "tel": "01000001111",
            "department": "컴퓨터공학과",
            "cardinals": [
                3
            ],
            "position": "BE",
            "status": "BANNED",
            "role": "USER",
            "attendanceCount": 1,
            "absenceCount": 9,
            "attendanceRate": 10,
            "penaltyCount": 9,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 24,
            "name": "Victor",
            "email": "[email protected]",
            "studentId": "2025022",
            "tel": "01022223333",
            "department": "소프트웨어전공",
            "cardinals": [
                2
            ],
            "position": "FE",
            "status": "ACTIVE",
            "role": "USER",
            "attendanceCount": 9,
            "absenceCount": 1,
            "attendanceRate": 90,
            "penaltyCount": 1,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 26,
            "name": "Xander",
            "email": "[email protected]",
            "studentId": "2025024",
            "tel": "01044445555",
            "department": "컴퓨터공학과",
            "cardinals": [
                2
            ],
            "position": "BE",
            "status": "LEFT",
            "role": "USER",
            "attendanceCount": 5,
            "absenceCount": 5,
            "attendanceRate": 50,
            "penaltyCount": 5,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 8,
            "name": "Frank",
            "email": "[email protected]",
            "studentId": "2025006",
            "tel": "01066667777",
            "department": "산업공학과",
            "cardinals": [
                2
            ],
            "position": "D",
            "status": "BANNED",
            "role": "USER",
            "attendanceCount": 5,
            "absenceCount": 5,
            "attendanceRate": 50,
            "penaltyCount": 5,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 9,
            "name": "Grace",
            "email": "[email protected]",
            "studentId": "2025007",
            "tel": "01077778888",
            "department": "시각디자인학과",
            "cardinals": [
                2
            ],
            "position": "BE",
            "status": "BANNED",
            "role": "USER",
            "attendanceCount": 4,
            "absenceCount": 6,
            "attendanceRate": 40,
            "penaltyCount": 6,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 10,
            "name": "Hank",
            "email": "[email protected]",
            "studentId": "2025008",
            "tel": "01088889999",
            "department": "소프트웨어전공",
            "cardinals": [
                2
            ],
            "position": "FE",
            "status": "BANNED",
            "role": "USER",
            "attendanceCount": 3,
            "absenceCount": 7,
            "attendanceRate": 30,
            "penaltyCount": 7,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 25,
            "name": "Wendy",
            "email": "[email protected]",
            "studentId": "2025023",
            "tel": "01033334444",
            "department": "인공지능전공",
            "cardinals": [
                2
            ],
            "position": "D",
            "status": "BANNED",
            "role": "USER",
            "attendanceCount": 8,
            "absenceCount": 2,
            "attendanceRate": 80,
            "penaltyCount": 2,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 2,
            "name": "admin1",
            "email": "[email protected]",
            "studentId": "2025123456",
            "tel": "0109877212",
            "department": "소프트웨어전공",
            "cardinals": [
                1
            ],
            "position": "BE",
            "status": "ACTIVE",
            "role": "ADMIN",
            "attendanceCount": 0,
            "absenceCount": 0,
            "attendanceRate": 0,
            "penaltyCount": 0,
            "createdAt": "2025-01-22T14:39:28.780643",
            "modifiedAt": "2025-01-22T14:39:28.780643"
        },
        {
            "id": 4,
            "name": "Bob",
            "email": "[email protected]",
            "studentId": "2025002",
            "tel": "01022223333",
            "department": "컴퓨터공학과",
            "cardinals": [
                1
            ],
            "position": "FE",
            "status": "ACTIVE",
            "role": "USER",
            "attendanceCount": 9,
            "absenceCount": 1,
            "attendanceRate": 90,
            "penaltyCount": 1,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 5,
            "name": "Charlie",
            "email": "[email protected]",
            "studentId": "2025003",
            "tel": "01033334444",
            "department": "경제학과",
            "cardinals": [
                1
            ],
            "position": "D",
            "status": "ACTIVE",
            "role": "USER",
            "attendanceCount": 8,
            "absenceCount": 2,
            "attendanceRate": 80,
            "penaltyCount": 2,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 6,
            "name": "Daisy",
            "email": "[email protected]",
            "studentId": "2025004",
            "tel": "01044445555",
            "department": "인공지능전공",
            "cardinals": [
                1
            ],
            "position": "BE",
            "status": "ACTIVE",
            "role": "ADMIN",
            "attendanceCount": 10,
            "absenceCount": 0,
            "attendanceRate": 100,
            "penaltyCount": 0,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 20,
            "name": "Rachel",
            "email": "[email protected]",
            "studentId": "2025018",
            "tel": "01088889999",
            "department": "경제학과",
            "cardinals": [
                1
            ],
            "position": "D",
            "status": "WAITING",
            "role": "USER",
            "attendanceCount": 8,
            "absenceCount": 2,
            "attendanceRate": 80,
            "penaltyCount": 1,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 21,
            "name": "Steve",
            "email": "[email protected]",
            "studentId": "2025019",
            "tel": "01099990000",
            "department": "경영학과",
            "cardinals": [
                1
            ],
            "position": "BE",
            "status": "WAITING",
            "role": "USER",
            "attendanceCount": 4,
            "absenceCount": 6,
            "attendanceRate": 60,
            "penaltyCount": 4,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        },
        {
            "id": 22,
            "name": "Tina",
            "email": "[email protected]",
            "studentId": "2025020",
            "tel": "01000001111",
            "department": "산업공학과",
            "cardinals": [
                1
            ],
            "position": "FE",
            "status": "WAITING",
            "role": "USER",
            "attendanceCount": 10,
            "absenceCount": 0,
            "attendanceRate": 100,
            "penaltyCount": 0,
            "createdAt": "2025-01-23T00:01:20",
            "modifiedAt": "2025-01-23T00:01:20"
        }
    ]
}

주의사항


체크 리스트

  • 리뷰어 설정
  • Assignee 설정
  • Label 설정
  • 제목 양식 맞췄나요? (ex. #0 Feat: 기능 추가)
  • 변경 사항에 대한 테스트

@jj0526 jj0526 requested review from hyxklee and huncozyboy January 22, 2025 15:54
@jj0526 jj0526 self-assigned this Jan 22, 2025
@jj0526 jj0526 linked an issue Jan 22, 2025 that may be closed by this pull request
Copy link
Member

@hyxklee hyxklee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨어요! 추가적인 방법 적어뒀습니다.
그리고 NAME_ASCENDING의 경우도 현재 성능 최적화가 안된 상태로 있을거에요! 두 가지 조회 방식을 같이 작업해주시면 좋을 것 같아요

return userGetService.findAll().stream()
.sorted(Comparator.comparingInt((user -> (StatusPriority.fromStatus(user.getStatus())).getPriority())))
.map(user -> {
List<UserCardinal> userCardinals = userCardinalGetService.getUserCardinals(user);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user 수 만큼 UserCardinals를 조회할 때 반복 쿼리가 많이 나갈 것 같아요!
조회해온 User 만큼의 UserCardinals를 한 번에 조회해서 Map으로 캐싱을 해두고, 그 데이터로 정렬을 해보는 것은 어떨까요?

그렇게 되면 쿼리는 UserList 조회, UserCardinals 조회 2번으로 해결할 수 있고, 메모리 위에서 정렬을 하니 속도가 증가할 것 같아요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor #112 기수별 조회 응답 속도 개선
2 participants