From b4744291d62e117b91f14d3c915b00f11dc54f06 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 25 2019 16:15:51 +0000 Subject: Add support for restricting the issues search to certain identifiers Basically you can now restrict the issues search to the ones containing the provided identifier (providing, not matching). This will allow the UI to get only the tickets of interest. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/query.py b/pagure/lib/query.py index af0619c..078aeac 100644 --- a/pagure/lib/query.py +++ b/pagure/lib/query.py @@ -47,8 +47,7 @@ import sqlalchemy.schema import werkzeug from six.moves.urllib_parse import urlparse, urlencode, parse_qsl -from sqlalchemy import func -from sqlalchemy import asc, desc +from sqlalchemy import asc, desc, func, cast, Text from sqlalchemy.orm import aliased from flask import url_for @@ -2728,6 +2727,7 @@ def search_issues( count=False, offset=None, limit=None, + search_id=None, search_pattern=None, search_content=None, custom_search=None, @@ -2788,6 +2788,8 @@ def search_issues( :kwarg count: a boolean to specify if the method should return the list of Issues or just do a COUNT query. :type count: boolean + :kwarg search_id: an integer to search in issues identifier + :type search_id: int or None :kwarg search_pattern: a string to search in issues title :type search_pattern: str or None :kwarg search_content: a string to search in the issues comments @@ -3021,6 +3023,11 @@ def search_issues( model.Issue.title.ilike("%%%s%%" % search_pattern) ) + if search_id is not None: + query = query.filter( + cast(model.Issue.id, Text).ilike("%%%s%%" % search_id) + ) + column = model.Issue.date_created if order_key: # If we are ordering by assignee, then order by the assignees'