Skip to content

Commit c1b90ba

Browse files
fetch_last_answer and fetch_code respect term_start_date
1 parent 236f942 commit c1b90ba

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

components/rsptx/db/crud/rslogging.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from ..models import (
77
Useinfo,
88
UseinfoValidation,
9+
Courses,
910
CoursesValidator,
1011
Code,
1112
CodeValidator,
@@ -169,12 +170,14 @@ async def fetch_last_answer_table_entry(
169170
deadline_offset_naive = query_data.deadline.replace(tzinfo=None)
170171
query = (
171172
select(tbl)
173+
.join(Courses, Courses.course_name == tbl.course_name)
172174
.where(
173175
and_(
174176
tbl.div_id == query_data.div_id,
175177
tbl.course_name == query_data.course,
176178
tbl.sid == query_data.sid,
177179
tbl.timestamp <= deadline_offset_naive,
180+
tbl.timestamp >= Courses.term_start_date,
178181
)
179182
)
180183
.order_by(tbl.timestamp.desc())
@@ -238,7 +241,13 @@ async def fetch_code(
238241
"""
239242
query = (
240243
select(Code)
241-
.where((Code.sid == sid) & (Code.acid == acid) & (Code.course_id == course_id))
244+
.join(Courses, Courses.id == Code.course_id)
245+
.where(
246+
(Code.sid == sid)
247+
& (Code.acid == acid)
248+
& (Code.course_id == course_id)
249+
& (Code.timestamp >= Courses.term_start_date)
250+
)
242251
.order_by(Code.id.desc())
243252
)
244253
if limit > 0:

0 commit comments

Comments
 (0)