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

[BE] 요구사항에 따른 코드 래픽토링 #42

Merged
merged 6 commits into from
Aug 7, 2023
Merged

Conversation

JJONSOO
Copy link

@JJONSOO JJONSOO commented Aug 4, 2023

What is this PR? 👓

요구사항에 따른 코드 래픽토링

Key changes 🔑

Issue Response에서 textColor, backgroundColor 추가
ErrorResponse에서 CustomException Message를 가지도록 한다.

To reviewers 👋

+ "GROUP_CONCAT( l.id ORDER BY l.id SEPARATOR ',') AS label_ids, "
+ "GROUP_CONCAT( l.title ORDER BY l.id SEPARATOR ',') AS label_titles, "
+ "GROUP_CONCAT( l.text_color ORDER BY l.id SEPARATOR ',') AS label_text_colors,"
+ "GROUP_CONCAT( l.background_color ORDER BY l.id SEPARATOR ',') AS label_background_colors,"
Copy link

@Ojeegu Ojeegu Aug 4, 2023

Choose a reason for hiding this comment

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

이 쿼리문 실행하면 issue id = 1(with label 1, 2)일 때 아래와 같은 응답이 반환됩니다.

{
    "success": true,
    "data": {
        "id": 1,
        "isOpen": true,
        "title": "issue_title",
        "labels": [
            {
                "id": 1,
                "title": "label_title1",
                "textColor": "0#9999",
                "backgroundColor": "0#8888"
            },
            {
                "id": 1,
                "title": "label_title1",
                "textColor": "0#9999",
                "backgroundColor": "0#8888"
            },
            {
                "id": 2,
                "title": "label_title2",
                "textColor": "0#9999",
                "backgroundColor": "0#8888"
            },
            {
                "id": 2,
                "title": "label_title2",
                "textColor": "0#9999",
                "backgroundColor": "0#8888"
            }
        ],
        "assignees": [
            {
                "id": 1,
                "name": "June"
            },
            {
                "id": 2,
                "name": "Movie"
            }
        ],
        "writer": {
            "id": 1,
            "name": "June"
        },
        "milestone": {
            "id": 1,
            "title": "milestone_title"
        },
        "history": {
            "editor": "2",
            "modifiedAt": "2023-08-04T22:45:21.86318"
        },
        "comments": null
    }
}

그리고 issue id = 2(with label 1)일때는 아래와 같이 반환됩니다.

{
    "success": true,
    "data": {
        "id": 2,
        "isOpen": false,
        "title": "issue_title2",
        "labels": [
            {
                "id": 2,
                "title": "label_title2",
                "textColor": "0#9999",
                "backgroundColor": "0#8888"
            }
        ],
        "assignees": [
            {
                "id": 1,
                "name": "June"
            }
        ],
        "writer": {
            "id": 1,
            "name": "June"
        },
        "milestone": {
            "id": 1,
            "title": "milestone_title"
        },
        "history": {
            "editor": "2",
            "modifiedAt": "2023-08-04T22:45:21.86318"
        },
        "comments": null
    }
}

issue_label과 label 조인 관련해서 중복 현상이 발생하는 것 같아요. 월요일에 SQL문 수정이 필요합니다.😢

Copy link
Author

@JJONSOO JJONSOO Aug 4, 2023

Choose a reason for hiding this comment

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

쿼리문을 수정하고, 전체적인 코드를 수정하였습니다.

이전엔 FilterMapper, IssueRepository에서 레이블에 대한 정보들(Id, title, textColor, backgroundColor)들을 한번에 가져왔으나, textColor, backgroundColor 에서 같은 값이 있는 경우 SQL 에서 DISTINCT을 사용하게 되면, Label의 Id의 총 개수와 다른 개수의 결과를 반환합니다.

이에 따라 FilterMapper, IssueRepository에서 Label의 Id 들만 가져온 후 다시 직접 찾아 LabelResponse로 변환하는 작업을 진행하였습니다.
반환 결과는 다음과 같습니다.
issue id = 1(with label 1, 2,3)

{
    "success": true,
    "data": {
        "labelCount": 3,
        "mileStoneCount": 1,
        "openIssueCount": 1,
        "closedIssueCount": 1,
        "issues": [
            {
                "id": 1,
                "isOpen": true,
                "title": "issue_title",
                "history": {
                    "editor": "Movie",
                    "modifiedAt": "2023-08-05T00:32:47.475332"
                },
                "labels": [
                    {
                        "id": 1,
                        "title": "label_title1",
                        "textColor": "0#9999",
                        "backgroundColor": "0#8888"
                    },
                    {
                        "id": 2,
                        "title": "label_title2",
                        "textColor": "0#9999",
                        "backgroundColor": "0#8888"
                    },
                    {
                        "id": 3,
                        "title": "label_title3",
                        "textColor": "0#8888",
                        "backgroundColor": "0#7777"
                    }
                ],
                "assignees": [
                    {
                        "id": 1,
                        "name": "June"
                    },
                    {
                        "id": 2,
                        "name": "Movie"
                    }
                ],
                "writer": {
                    "id": 1,
                    "name": "June"
                },
                "milestone": {
                    "id": 1,
                    "title": "milestone_title"
                }
            }
        ]
    }
}

그리고 issue id = 2(with label 2)일때는 아래와 같이 반환하도록 수정하였습니다.

{
    "success": true,
    "data": {
        "id": 2,
        "isOpen": false,
        "title": "issue_title2",
        "labels": [
            {
                "id": 2,
                "title": "label_title2",
                "textColor": "0#9999",
                "backgroundColor": "0#8888"
            }
        ],
        "assignees": [
            {
                "id": 1,
                "name": "June"
            }
        ],
        "writer": {
            "id": 1,
            "name": "June"
        },
        "milestone": {
            "id": 1,
            "title": "milestone_title"
        },
        "history": {
            "editor": "2",
            "modifiedAt": "2023-08-05T00:45:32.692085"
        },
        "comments": null
    }
}

메인페이지엔 다음과 같이 반환합니다.

{
    "success": true,
    "data": {
        "labelCount": 3,
        "mileStoneCount": 1,
        "openIssueCount": 1,
        "closedIssueCount": 1,
        "issues": [
            {
                "id": 1,
                "isOpen": true,
                "title": "issue_title",
                "history": {
                    "editor": "Movie",
                    "modifiedAt": "2023-08-05T00:44:48.255545"
                },
                "labels": [
                    {
                        "id": 1,
                        "title": "label_title1",
                        "textColor": "0#9999",
                        "backgroundColor": "0#8888"
                    },
                    {
                        "id": 2,
                        "title": "label_title2",
                        "textColor": "0#9999",
                        "backgroundColor": "0#8888"
                    },
                    {
                        "id": 3,
                        "title": "label_title3",
                        "textColor": "0#8888",
                        "backgroundColor": "0#7777"
                    }
                ],
                "assignees": [
                    {
                        "id": 1,
                        "name": "June"
                    },
                    {
                        "id": 2,
                        "name": "Movie"
                    }
                ],
                "writer": {
                    "id": 1,
                    "name": "June"
                },
                "milestone": {
                    "id": 1,
                    "title": "milestone_title"
                }
            }
        ]
    }
}

@JJONSOO JJONSOO merged commit f9ceea5 into be Aug 7, 2023
@JJONSOO JJONSOO deleted the feat/#37-refactoring branch August 7, 2023 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants