Skip to content

Commit

Permalink
Revert error handling (stale events are better than nothing)
Browse files Browse the repository at this point in the history
This is done so empty calendars are not produced on errors (effectively
removing all events from the user's calendar). Calendar apps tend to
leave old events in place if they fail to update them (non-200 response)
and it seems like it's better to have stale events rather than nothing
while the error is being fixed.
  • Loading branch information
iburakov committed Sep 23, 2023
1 parent e9ac0ce commit 731e4a7
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 21 deletions.
4 changes: 0 additions & 4 deletions src/main_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

from aiohttp import ClientSession

from utils.error_handling import catch_errors_to_empty_iter

logger = logging.getLogger(__name__)

_API_BASE_URL = "https://my.itmo.ru/api"
Expand All @@ -34,14 +32,12 @@ async def _get_calendar(session: ClientSession, auth_token: str, path: str) -> d
return await resp.json()


@catch_errors_to_empty_iter
async def get_raw_lessons(session: ClientSession, auth_token: str) -> Iterable[dict]:
resp_json = await _get_calendar(session, auth_token, "/schedule/schedule/personal")
days = resp_json["data"]
return (dict(date=day["date"], **lesson) for day in days for lesson in day["lessons"])


@catch_errors_to_empty_iter
async def get_raw_pe_lessons(session: ClientSession, auth_token: str) -> Iterable[dict]:
resp_json = await _get_calendar(session, auth_token, "/sport/my_sport/calendar")
days = resp_json["result"]
Expand Down
Empty file removed src/utils/__init__.py
Empty file.
17 changes: 0 additions & 17 deletions src/utils/error_handling.py

This file was deleted.

0 comments on commit 731e4a7

Please sign in to comment.