@@ -173,25 +173,44 @@ async def get_projects_mapped(user_id: int, db: Database):
173173 @staticmethod
174174 async def get_and_save_stats (user_id : int , db : Database ) -> dict :
175175 hashtag = settings .DEFAULT_CHANGESET_COMMENT .replace ("#" , "" )
176- url = (
176+ oh_some_url = (
177177 f"{ settings .OHSOME_STATS_API_URL } /stats/user?"
178178 f"hashtag={ hashtag } -%2A&userId={ user_id } "
179179 f"&topics={ settings .OHSOME_STATS_TOPICS } "
180180 )
181181 osm_user_details_url = f"{ settings .OSM_SERVER_URL } /api/0.6/user/{ user_id } .json"
182- headers = {"Authorization" : f"Basic { settings .OHSOME_STATS_TOKEN } " }
182+
183+ oh_some_headers = {"Authorization" : f"Basic { settings .OHSOME_STATS_TOKEN } " }
183184
184185 async with AsyncClient (timeout = 10.0 ) as client :
185- response = await client .get (url , headers = headers )
186+ oh_some_response = await client .get (oh_some_url , headers = oh_some_headers )
186187 changeset_response = await client .get (osm_user_details_url )
187188
188- if response .status_code != 200 :
189- raise UserServiceError ("External-Error in Ohsome API" )
189+ if oh_some_response .status_code != 200 :
190+ error_msg = (
191+ "External-Error in Ohsome API: url=%s status_code=%s response=%s"
192+ % (
193+ oh_some_url ,
194+ oh_some_response .status_code ,
195+ oh_some_response .text [:500 ],
196+ )
197+ )
198+ logger .exception (error_msg )
199+ return {}
190200
191- topic_data = response .json ()
201+ topic_data = oh_some_response .json ()
192202
193203 if changeset_response .status_code != 200 :
194- raise UserServiceError ("External-Error in OSM API" )
204+ error_msg = (
205+ "External-Error in OSM API: url=%s status_code=%s response=%s"
206+ % (
207+ osm_user_details_url ,
208+ changeset_response .status_code ,
209+ changeset_response .text [:500 ],
210+ )
211+ )
212+ logger .exception (error_msg )
213+ return {}
195214
196215 changeset_data = changeset_response .json ()
197216
0 commit comments