-
Notifications
You must be signed in to change notification settings - Fork 1
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
optimize getlecture #53
base: main
Are you sure you want to change the base?
Changes from 1 commit
41520cf
bc71692
7ab8129
4252850
ae0ce87
acd6af0
e7479aa
c027182
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,21 +121,20 @@ async def get_lecturers( | |
if "comments" in info and approved_comments: | ||
lecturer_to_result.comments = approved_comments | ||
if "mark" in info and approved_comments: | ||
lecturer_to_result.mark_freebie = sum([comment.mark_freebie for comment in approved_comments]) / len( | ||
approved_comments | ||
) | ||
lecturer_to_result.mark_kindness = sum(comment.mark_kindness for comment in approved_comments) / len( | ||
approved_comments | ||
) | ||
lecturer_to_result.mark_clarity = sum(comment.mark_clarity for comment in approved_comments) / len( | ||
approved_comments | ||
) | ||
result.mark_freebie, result.mark_kindness, result.mark_clarity = 0, 0, 0 | ||
|
||
for comment in approved_comments: | ||
result.mark_freebie += comment.mark_freebie | ||
result.mark_kindness += comment.mark_kindness | ||
result.mark_clarity += comment.mark_clarity | ||
|
||
general_marks = [ | ||
lecturer_to_result.mark_freebie, | ||
lecturer_to_result.mark_kindness, | ||
lecturer_to_result.mark_clarity, | ||
result.mark_freebie / len(approved_comments), | ||
result.mark_kindness / len(approved_comments), | ||
result.mark_clarity / len(approved_comments), | ||
] | ||
lecturer_to_result.mark_general = sum(general_marks) / len(general_marks) | ||
result.mark_general = sum(general_marks) / len(general_marks) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. result изначально имеет вид: class LecturerGetAll(Base):
lecturers: list[LecturerGet] = []
limit: int
offset: int
total: int А тут вместо добавления оценок лекторам, создаются новые поля в result и перезаписываются при каждой итерации по лектору There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Аналогично нужно поправить ручку get_lecturer |
||
if approved_comments: | ||
lecturer_to_result.subjects = list({comment.subject for comment in approved_comments}) | ||
result.lecturers.append(lecturer_to_result) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Также выкатили пр на тесты, так что стоит написать тесты на: