Skip to content

Commit 236f942

Browse files
Book fetch_page_activity_counts respects term_start_date
1 parent e1f0a3e commit 236f942

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

components/rsptx/db/crud/book.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from ..models import (
55
Chapter,
66
ChapterValidator,
7+
Courses,
78
SubChapter,
89
SubChapterValidator,
910
Question,
@@ -137,11 +138,16 @@ async def fetch_page_activity_counts(
137138
page_divids = await session.execute(query)
138139
rslogger.debug(f"PDVD {page_divids}")
139140
div_counts = {q.name: 0 for q in page_divids.scalars()}
140-
query = select(distinct(Useinfo.div_id)).where(
141-
where_clause_common
142-
& (Question.name == Useinfo.div_id)
143-
& (Useinfo.course_id == course_name)
144-
& (Useinfo.sid == username)
141+
query = (
142+
select(distinct(Useinfo.div_id))
143+
.join(Courses, Courses.course_name == Useinfo.course_id)
144+
.where(
145+
where_clause_common
146+
& (Question.name == Useinfo.div_id)
147+
& (Useinfo.course_id == course_name)
148+
& (Useinfo.sid == username)
149+
& (Useinfo.timestamp > Courses.term_start_date)
150+
)
145151
)
146152
async with async_session() as session:
147153
sid_counts = await session.execute(query)

0 commit comments

Comments
 (0)