Skip to content

Commit

Permalink
Request timetable data for one day only
Browse files Browse the repository at this point in the history
  • Loading branch information
BelKed committed Jul 16, 2024
1 parent bde6181 commit 7a1ff24
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions edupage_api/foreign_timetables.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ class LessonSkeleton:


class ForeignTimetables(Module):
def __get_this_week_weekday(self, date: date, n: int) -> date:
return date - timedelta(days=(date.weekday() - n))

def get_school_year(self):
dp = self.edupage.data.get("dp")

Expand All @@ -43,19 +40,16 @@ def get_school_year(self):

return dp.get("year")

def __get_timetable_data(self, id: int, table: str, date: date):
this_monday = self.__get_this_week_weekday(date, 0)
this_sunday = self.__get_this_week_weekday(date, 6)

def __get_timetable_data(self, target_id: int, table: str, date: date):
request_data = {
"__args": [
None,
{
"year": self.get_school_year(),
"datefrom": this_monday.strftime("%Y-%m-%d"),
"dateto": this_sunday.strftime("%Y-%m-%d"),
"datefrom": date.strftime("%Y-%m-%d"),
"dateto": date.strftime("%Y-%m-%d"),
"table": table,
"id": str(id),
"id": str(target_id),
"showColors": True,
"showIgroupsInClasses": True,
"showOrig": True,
Expand Down Expand Up @@ -115,13 +109,6 @@ def get_foreign_timetable(

skeletons = []
for skeleton in timetable_data:
date_str = skeleton.get("date")
lesson_date = datetime.strptime(date_str, "%Y-%m-%d")

# Skip lessons from other days
if lesson_date != date:
continue

period_str = skeleton.get("uniperiod")
period = int(period_str) if period_str.isdigit() else None

Expand Down

0 comments on commit 7a1ff24

Please sign in to comment.