Skip to content

Commit 7adaa79

Browse files
authored
Fix/116 thumbnail and member api (#117)
- 멤버 정보를 얻는 api에서 기수(내림차순), 포지션 순서(ANDROID, IOS, FRONTEND, BACKEND, DESIGNER) 순서로 정렬되어 출력할 수 있게 수정했습니다 - s3에 저장된 이미지의 경우, 브라우저에서 캐싱이 가능하도록, post presigned url을 생성할 때 cache control 필드를 추가해줬습니다. - ProjectURLType Enum에 DATA_GITHUB을 추가했습니다.
1 parent 1c60a1e commit 7adaa79

File tree

6 files changed

+115
-8
lines changed

6 files changed

+115
-8
lines changed

wacruit/src/apps/common/enums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ class Position(Enum):
8888
IOS = "IOS"
8989
# INFRA = 6
9090
# PM = 7
91-
# OPERATIONS = 8
9291

9392

9493
class SeminarType(Enum):
@@ -108,6 +107,7 @@ class ProjectURLType(Enum):
108107
WEBSITE = "WEBSITE"
109108
IOS_GITHUB = "IOS_GITHUB"
110109
CRAWLER_GITHUB = "CRAWLER_GITHUB"
110+
DATA_GITHUB = "DATA_GITHUB"
111111
BEHANCE = "BEHANCE"
112112

113113

wacruit/src/apps/member/repositories.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
from fastapi import Depends
2+
from sqlalchemy import case
3+
from sqlalchemy import cast
4+
from sqlalchemy import Float
5+
from sqlalchemy import null
26
from sqlalchemy.orm import Session
37

48
from wacruit.src.apps.common.enums import Position
@@ -27,7 +31,28 @@ def create_member(self, member: Member) -> Member:
2731
def get_all_members(
2832
self, position: Position | None, offset: int, limit: int
2933
) -> list[Member]:
30-
query = self.session.query(Member)
34+
# generation을 숫자로 캐스트하여 내림차순 정렬, NULL은 뒤로 보내기
35+
safe_num = case(
36+
(
37+
Member.generation.op("REGEXP")("^[0-9]+(\\.[0-9]+)?$"),
38+
cast(Member.generation, Float),
39+
),
40+
else_=null(),
41+
)
42+
43+
# ANDROID, IOS, FRONTEND, BACKEND, DESIGNER 순서로 정렬
44+
position_order = case(
45+
(Member.position == Position.ANDROID, 1),
46+
(Member.position == Position.IOS, 2),
47+
(Member.position == Position.FRONTEND, 3),
48+
(Member.position == Position.BACKEND, 4),
49+
(Member.position == Position.DESIGNER, 5),
50+
else_=6,
51+
)
52+
53+
query = self.session.query(Member).order_by(
54+
safe_num.desc(), position_order.asc()
55+
)
3156

3257
if position is not None:
3358
query = query.where(Member.position == position)

wacruit/src/apps/member/schemas.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ class MemberInfoResponse(OrmModel):
2121
first_name: str
2222
last_name: str
2323
introduction: str | None = None
24-
department: str
25-
college: str
26-
phone_number: str
27-
github_id: str
24+
department: str | None = None
25+
college: str | None = None
26+
phone_number: str | None = None
27+
github_id: str | None = None
2828
is_active: bool
2929
generation: str
30-
position: Position
30+
position: Position | None = None
3131

3232

3333
class MemberBriefResponse(OrmModel):

wacruit/src/apps/project/services.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ def generate_presigned_url_for_post_image(
234234
s3_client=self._s3_client.client,
235235
s3_bucket=self._s3_config.bucket_name,
236236
s3_object=object_name,
237+
fields={"Cache-Control": "max-age=7889400"},
237238
expires_in=_10_MIN,
238239
conditions=[
239240
["content-length-range", 0, _50_MB],
@@ -299,6 +300,7 @@ def update_project_image(self, file_id: int) -> PresignedUrlWithIdResponse:
299300
s3_bucket=self._s3_config.bucket_name,
300301
s3_object=project_image.object_key,
301302
expires_in=_10_MIN,
303+
fields={"Cache-Control": "max-age=7889400"},
302304
conditions=[["content-length-range", 0, _50_MB]],
303305
)
304306
return PresignedUrlWithIdResponse(

wacruit/src/apps/project/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ def delete_project_image(
9191
file_id: int,
9292
project_service: Annotated[ProjectService, Depends()],
9393
) -> None:
94-
project_service.delete_project_image(file_id=file_id)
94+
return project_service.delete_project_image(file_id=file_id)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
"""add DATA_GITHUB in ProjectURLType
2+
3+
Revision ID: 564952e2cd49
4+
Revises: 13ccaabc3ec3
5+
Create Date: 2025-11-12 23:03:32.895041
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
from sqlalchemy.dialects import mysql
11+
12+
# revision identifiers, used by Alembic.
13+
revision = "564952e2cd49"
14+
down_revision = "13ccaabc3ec3"
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade() -> None:
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.alter_column(
22+
"project_url",
23+
"url_type",
24+
existing_type=mysql.ENUM(
25+
"ANDROID_STORE",
26+
"IOS_STORE",
27+
"FRONTEND_GITHUB",
28+
"BACKEND_GITHUB",
29+
"ANDROID_GITHUB",
30+
"WEBSITE",
31+
"IOS_GITHUB",
32+
"CRAWLER_GITHUB",
33+
"BEHANCE",
34+
),
35+
type_=mysql.ENUM(
36+
"ANDROID_STORE",
37+
"IOS_STORE",
38+
"FRONTEND_GITHUB",
39+
"BACKEND_GITHUB",
40+
"ANDROID_GITHUB",
41+
"WEBSITE",
42+
"IOS_GITHUB",
43+
"CRAWLER_GITHUB",
44+
"DATA_GITHUB",
45+
"BEHANCE",
46+
),
47+
)
48+
# ### end Alembic commands ###
49+
50+
51+
def downgrade() -> None:
52+
# ### commands auto generated by Alembic - please adjust! ###
53+
op.alter_column(
54+
"project_url",
55+
"url_type",
56+
existing_type=mysql.ENUM(
57+
"ANDROID_STORE",
58+
"IOS_STORE",
59+
"FRONTEND_GITHUB",
60+
"BACKEND_GITHUB",
61+
"ANDROID_GITHUB",
62+
"WEBSITE",
63+
"IOS_GITHUB",
64+
"CRAWLER_GITHUB",
65+
"DATA_GITHUB",
66+
"BEHANCE",
67+
),
68+
type_=mysql.ENUM(
69+
"ANDROID_STORE",
70+
"IOS_STORE",
71+
"FRONTEND_GITHUB",
72+
"BACKEND_GITHUB",
73+
"ANDROID_GITHUB",
74+
"WEBSITE",
75+
"IOS_GITHUB",
76+
"CRAWLER_GITHUB",
77+
"BEHANCE",
78+
),
79+
)
80+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)