codedang
codedang copied to clipboard
chore(be): standardize the return format of 'get' apis
Description
Closes #1504
~~getProblems에서 총 Problem의 개수를 받아오는 api를 분리해 구현합니다.~~ ~~추가로, 종료된 contest를 가져올 때 finished 속성이 붙어 나오는 것을 제거하고, 배열만 반환하도록 수정합니다.~~
회의 결과에 따라 getProblems, getContests 등 take
인자를 필요로 하는 api들에 대해 data
, total
속성을 가지고 있는 객체를 반환합니다.
-
data
: 요청된 데이터가 담긴 배열 -
total
: 데이터의 총 개수 (take
와 상관 없이 조건에 맞는 데이터의 총 개수를 의미합니다)
예시(GET {{baseUrl}}/problem?take=5)
{
"data": [
{
"id": 1,
"title": "정수 더하기",
"engTitle": "Integer Addition",
"difficulty": "Level1",
"submissionCount": 0,
"acceptedRate": 0,
"tags": [
{
"id": 1,
"name": "If Statement"
}
]
},
{
"id": 2,
"title": "가파른 경사",
"engTitle": null,
"difficulty": "Level1",
"submissionCount": 0,
"acceptedRate": 0,
"tags": [
{
"id": 2,
"name": "Iteration"
}
]
},
{
"id": 3,
"title": "회전 표지판",
"engTitle": null,
"difficulty": "Level1",
"submissionCount": 0,
"acceptedRate": 0,
"tags": [
{
"id": 3,
"name": "Brute Force"
}
]
},
{
"id": 4,
"title": "붕어빵",
"engTitle": null,
"difficulty": "Level2",
"submissionCount": 0,
"acceptedRate": 0,
"tags": [
{
"id": 4,
"name": "DFS"
}
]
},
{
"id": 5,
"title": "채권관계",
"engTitle": null,
"difficulty": "Level2",
"submissionCount": 0,
"acceptedRate": 0,
"tags": [
{
"id": 5,
"name": "Dynamic Programming"
}
]
}
],
"total": 7
}
Before submitting the PR, please make sure you do the following
- [x] Read the Contributing Guidelines
- [x] Read the Contributing Guidelines and follow the Commit Convention
- [x] Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g.
fixes #123
). - [x] Ideally, include relevant tests that fail without this PR but pass with it.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Updated (UTC) |
---|---|---|---|
codedang | ✅ Ready (Inspect) | Visit Preview | May 23, 2024 2:21pm |
이번에 contest 속의 config가 없어져가지고 그부분 수정가능할까요오?! 아마 위의 에러도 그거때문에 뜨는걸거에요 . . .
이번에 contest 속의 config가 없어져가지고 그부분 수정가능할까요오?!
아마 위의 에러도 그거때문에 뜨는걸거에요 . . .
네 해결해서 다시 올려놓을게요~
일부 메서드에서 findMany()
의 where
조건과 count()
의 where
조건이 다른데
Pagination을 적용하면 프론트엔드 쪽에서 실제 데이터 페이지 수보다 더 많거나 적은 페이지가 존재한다고 표시될 수도 있을거 같아서
특별히 where
조건을 다르게 설정한 이유가 있을까요??
일부 메서드에서
findMany()
의where
조건과count()
의where
조건이 다른데 Pagination을 적용하면 프론트엔드 쪽에서 실제 데이터 페이지 수보다 더 많거나 적은 페이지가 존재한다고 표시될 수도 있을거 같아서 특별히where
조건을 다르게 설정한 이유가 있을까요??
count의 조건을 잘못 준 부분이 있어서 수정해놓았습니다!