@@ -47,13 +47,19 @@ async def create_post(
4747 ** post_data .dict (),
4848 user_id = user .id
4949 )
50+ if post .type == "disaster" :
51+ user .point += 10
52+ elif post .type == "normal" :
53+ user .point += 5
54+ self .session .add (user )
5055 self .session .add (post )
5156 self .session .commit ()
5257 self .session .refresh (post )
5358 author = Author (
5459 id = user .id ,
5560 username = user .username ,
56- profile_imageURL = user .profile_imageURL
61+ profile_imageURL = user .profile_imageURL ,
62+ point = user .point
5763 )
5864 return self ._serialize_post (post , author )
5965
@@ -106,7 +112,8 @@ async def update_post(
106112 author = Author (
107113 id = user .id ,
108114 username = user .username ,
109- profile_imageURL = user .profile_imageURL
115+ profile_imageURL = user .profile_imageURL ,
116+ point = user .point
110117 )
111118 return self ._serialize_post (post , author )
112119
@@ -143,7 +150,8 @@ def list_posts(self, term: str = None, type: str = None, region_ids: list = None
143150 Author (
144151 id = post .user .id ,
145152 username = post .user .username ,
146- profile_imageURL = post .user .profile_imageURL
153+ profile_imageURL = post .user .profile_imageURL ,
154+ point = post .user .point
147155 )
148156 )
149157 for post in posts
@@ -154,7 +162,8 @@ def list_user_posts(self, user: User):
154162 author = Author (
155163 id = user .id ,
156164 username = user .username ,
157- profile_imageURL = user .profile_imageURL
165+ profile_imageURL = user .profile_imageURL ,
166+ point = user .point
158167 )
159168 return [self ._serialize_post (post , author ) for post in posts ]
160169
@@ -171,6 +180,7 @@ def increment_view_count(self, post_id: int):
171180 author = Author (
172181 id = post .user .id ,
173182 username = post .user .username ,
174- profile_imageURL = post .user .profile_imageURL
183+ profile_imageURL = post .user .profile_imageURL ,
184+ point = post .user .point
175185 )
176186 return self ._serialize_post (post , author )
0 commit comments