Skip to content

Filter by subject#129

Merged
Zimovchik merged 4 commits intomainfrom
filter_by_subject
May 3, 2025
Merged

Filter by subject#129
Zimovchik merged 4 commits intomainfrom
filter_by_subject

Conversation

@Zimovchik
Copy link
Copy Markdown
Member

Изменения

Детали реализации

Check-List

  • Вы проверили свой код перед отправкой запроса?
  • Вы написали тесты к реализованным функциям?
  • Вы не забыли применить форматирование black и isort для Back-End или Prettier для Front-End?

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2025

Code Coverage

Coverage Report
FileStmtsMissCoverMissing
rating_api
   __main__.py440%1–7
   exceptions.py43784%35–37, 48–50, 58
rating_api/models
   base.py64592%24–27, 94
   db.py107595%61, 75, 84, 134, 152
rating_api/routes
   base.py16194%41
   comment.py1113073%65, 83, 124–126, 147–156, 222–223, 225–226, 234–239, 266, 279, 306–317
   exc_handlers.py32391%36, 43, 50
   lecturer.py891682%136, 141–167, 183, 191, 209, 215
rating_api/schemas
   base.py12467%6–9
   models.py138398%102–104
TOTAL6587888% 

Summary

Tests Skipped Failures Errors Time
51 0 💤 0 ❌ 0 🔥 9.660s ⏱️

@Zimovchik Zimovchik requested a review from Copilot May 3, 2025 08:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a “subject” filter to the comments endpoint, allowing requests to filter comments by subject, while also modifying the behavior of existing lecturer-based filtering.

  • Added an optional “subject” query parameter in the get_comments route.
  • Introduced a new search_by_subject method in the Comment model.
  • Updated search_by_lectorer_id to remove the review status condition.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
rating_api/routes/comment.py Added subject parameter and applied subject filter in the route
rating_api/models/db.py Added search_by_subject method and modified search_by_lectorer_id behavior
Comments suppressed due to low confidence (1)

rating_api/models/db.py:140

  • The change in search_by_lectorer_id removes the filtering by ReviewStatus.APPROVED, which may result in unexpected behavior. Please verify if this change is intentional or if the condition should be retained to ensure only approved comments are returned.
return Comment.lecturer_id == query

Comment thread rating_api/models/db.py Outdated
def search_by_subject(self, query: str) -> bool:
if not query:
return true()
return func.lower(Comment.subject).contains(query)
Copy link

Copilot AI May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider converting the query parameter to lower case before performing the contains operation for a consistent case-insensitive comparison.

Suggested change
return func.lower(Comment.subject).contains(query)
return func.lower(Comment.subject).contains(query.lower())

Copilot uses AI. Check for mistakes.
@Zimovchik Zimovchik merged commit fe95614 into main May 3, 2025
2 checks passed
@Zimovchik Zimovchik deleted the filter_by_subject branch May 3, 2025 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants