Skip to content

Commit

Permalink
search in note info
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdinazor committed Mar 17, 2022
1 parent f360fc3 commit c175939
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/note_service/modules/rest/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ def create_note(files, args, username):

def search_notes(args, pagination_parameters):
tag = args.get("tag")
_response = Notes.query.filter(Notes.tag.contains([tag])).order_by(Notes.created_date.desc()).paginate(pagination_parameters.page, pagination_parameters.page_size)
note_info = args.get("note_info")
_response = Notes.query
if note_info:
_response = _response.filter(Notes.note_info.ilike("%" + note_info + "%"))
_response = _response.filter(Notes.tag.contains([tag])).order_by(Notes.created_date.desc()).paginate(pagination_parameters.page, pagination_parameters.page_size)
pagination_parameters.item_count = _response.total
return ResponseObject(data=_response.items,
page=PaginationObject(page=_response.page, total_pages=_response.pages,
Expand Down
2 changes: 1 addition & 1 deletion src/note_service/modules/rest/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Meta:


class NoteSearch(Note):
note_info = fields.String(dump_only=True)
note_info = fields.String(required=False)
tag = fields.String(required=True)


Expand Down

0 comments on commit c175939

Please sign in to comment.