Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opt get timetable #110

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions calendar_backend/routes/event/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from calendar_backend.exceptions import NotEnoughCriteria
from calendar_backend.methods import list_calendar
from calendar_backend.models import Event, EventsGroups, EventsLecturers, EventsRooms, Group, Lecturer, Room
from calendar_backend.models import Event, Group, Lecturer, Room
from calendar_backend.routes.models import EventGet
from calendar_backend.routes.models.event import EventPatch, EventPost, GetListEvent
from calendar_backend.settings import get_settings
Expand All @@ -34,14 +34,11 @@ async def _get_timetable(start: date, end: date, group_id, lecturer_id, room_id,
Event.end_ts < end,
)
if group_id:
ids_ = EventsGroups.get_all(session=db.session).filter(EventsGroups.group_id == group_id).all()
events = events.filter(Event.id.in_(row.event_id for row in ids_))
events = events.filter(Event.group.any(Group.id == group_id))
elif lecturer_id:
ids_ = EventsLecturers.get_all(session=db.session).filter(EventsLecturers.lecturer_id == lecturer_id).all()
events = events.filter(Event.id.in_(row.event_id for row in ids_))
events = events.filter(Event.lecturer.any(Lecturer.id == lecturer_id))
elif room_id:
ids_ = EventsRooms.get_all(session=db.session).filter(EventsRooms.room_id == room_id).all()
events = events.filter(Event.id.in_(row.event_id for row in ids_))
events = events.filter(Event.room.any(Room.id == room_id))
cnt = events.count()
if limit:
events = events.order_by(Event.start_ts).limit(limit).offset(offset).all()
Expand Down
Loading