Skip to content

Commit ee4e25c

Browse files
committed
clean up random print statements
1 parent 9f0fd72 commit ee4e25c

4 files changed

Lines changed: 19 additions & 13 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ _build
3333
**/test/_static
3434
bake.log
3535
WARP.md
36+
.claude

components/rsptx/db/crud/book.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ async def get_book_subchapters(course_name: str) -> List[SubChapterValidator]:
105105
.order_by(Chapter.chapter_num, SubChapter.sub_chapter_num)
106106
)
107107
async with async_session() as session:
108-
print(query)
108+
rslogger.debug(f"{query=}")
109109
res = await session.execute(query)
110110
return [SubChapterValidator.from_orm(x) for x in res.scalars().fetchall()]
111111

components/rsptx/db/crud/course_attrs.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from sqlalchemy import select
22

3-
from ..models import CourseAttribute
3+
from ..models import CourseAttribute, Courses
44
from ..async_session import async_session
5+
from rsptx.logging import rslogger
56

67

78
async def fetch_all_course_attributes(course_id: int) -> dict:
@@ -48,27 +49,31 @@ async def copy_course_attributes(basecourse_id: int, new_course_id: int):
4849
async with async_session() as session:
4950
res = await session.execute(query)
5051
for row in res.scalars().fetchall():
51-
print(row.attr, row.value)
52+
rslogger.debug(f"copy_course_attributes: {row.attr}={row.value}")
5253
new_attr = CourseAttribute(
5354
course_id=new_course_id, attr=row.attr, value=row.value
5455
)
5556
session.add(new_attr)
5657
await session.commit()
5758

5859

59-
async def get_course_origin(base_course):
60+
async def get_course_origin(base_course: str):
6061
"""
61-
Retrieve the origin of a given course (base_course)
62+
Retrieve the origin (markup system) of a given course by its name.
6263
63-
:param base_course: str, the name of the base course
64-
:return: str, the origin of the course
64+
:param base_course: str, the name of the base course (i.e. ``courses.course_name``)
65+
:return: str, the value of the ``markup_system`` course attribute, or None if not found
6566
"""
66-
query = select(CourseAttribute).where(
67-
(CourseAttribute.course_id == base_course)
68-
& (CourseAttribute.attr == "markup_system")
67+
query = (
68+
select(CourseAttribute)
69+
.join(Courses, Courses.id == CourseAttribute.course_id)
70+
.where(
71+
(Courses.course_name == base_course)
72+
& (CourseAttribute.attr == "markup_system")
73+
)
6974
)
7075

7176
async with async_session() as session:
7277
res = await session.execute(query)
7378
ca = res.scalars().first()
74-
return ca.value
79+
return ca.value if ca else None

components/rsptx/db/crud/question.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,8 @@ async def fetch_questions_for_chapter_subchapter(
638638
Question.id,
639639
)
640640
)
641-
print(f"{query=}")
642-
print(f"{base_course=},{skipreading=},{from_source_only=},{pages_only=},{owner=}")
641+
rslogger.debug(f"{query=}")
642+
rslogger.debug(f"{base_course=},{skipreading=},{from_source_only=},{pages_only=},{owner=}")
643643
async with async_session() as session:
644644
res = await session.execute(query)
645645
rslogger.debug(f"{res=}")

0 commit comments

Comments
 (0)