Skip to content

Commit

Permalink
improve grouping and PlanLesson generation of internal lessons
Browse files Browse the repository at this point in the history
  • Loading branch information
Belissimo-T committed Jun 10, 2024
1 parent 928d690 commit 90c1bf1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions backend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Lesson:
_group_count: int = 1

_origin_plan_type: typing.Literal["forms", "teachers", "rooms"] = None
_origin_plan_lesson_ids: set[int] = None
_origin_plan_lesson_ids: set[int] = dataclasses.field(default_factory=set)
_is_scheduled: bool | None = None
_grouped_form_plan_current_course: str = None
_grouped_form_plan_current_teachers: set[str] = None
Expand Down Expand Up @@ -411,8 +411,16 @@ def _to_plan_lessons(lessons: list[Lesson], plan_type: typing.Literal["forms", "
if not taking_place_lesson.takes_place:
continue

if taking_place_lesson.is_internal:
out.append(
PlanLesson.create(taking_place_lesson, None, plan_type, plan_value)
)
continue

for not_taking_place_lesson in not_taking_place_lessons:
if taking_place_lesson._origin_plan_lesson_ids.issubset(not_taking_place_lesson._origin_plan_lesson_ids):
if taking_place_lesson._origin_plan_lesson_ids.issubset(
not_taking_place_lesson._origin_plan_lesson_ids
):
out.append(
PlanLesson.create(taking_place_lesson, not_taking_place_lesson, plan_type, plan_value)
)
Expand Down Expand Up @@ -603,6 +611,7 @@ def group_blocks_and_lesson_info(self, origin_plan_type: typing.Literal["forms",
previous_lesson_block = (next(iter(previous_lesson.periods)) + 1) // 2
current_lesson_block = (next(iter(lesson.periods)) + 1) // 2
can_get_grouped &= previous_lesson_block == current_lesson_block
can_get_grouped &= previous_lesson.is_internal == lesson.is_internal

if can_get_grouped:
if origin_plan_type == "forms":
Expand Down

0 comments on commit 90c1bf1

Please sign in to comment.