From fa7e4cf9642abb23db89e2f38882afdd54061ae6 Mon Sep 17 00:00:00 2001
From: “AnjaliPardeshi” <“anjalipardeshi92@gmail.com”>
Date: Oct 07 2016 21:01:48 +0000
Subject: [PATCH 1/5] Searches given word in title of issues.
Changes according to pep8
Docstring added for search pattern and pep8 changes
search bar and button added to input-group
---
diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py
index c5d0b70..0540e8b 100644
--- a/pagure/lib/__init__.py
+++ b/pagure/lib/__init__.py
@@ -1679,12 +1679,11 @@ def get_project(session, name, user=None, namespace=None):
return query.first()
-
def search_issues(
session, repo, issueid=None, issueuid=None, status=None,
closed=False, tags=None, assignee=None, author=None, private=None,
- priority=None, milestones=None,
- count=False, offset=None, limit=None):
+ priority=None, milestones=None, count=False, offset=None,
+ limit=None, search_pattern=None):
''' Retrieve one or more issues associated to a project with the given
criterias.
@@ -1731,6 +1730,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_pattern: a string to search in issues title
+ :type search_pattern: str or None
:return: A single Issue object if issueid is specified, a list of Project
objects otherwise.
@@ -1875,6 +1876,15 @@ def search_issues(
model.Issue.project_id == repo.id
)
+ if search_pattern is not None:
+ query = session.query(
+ model.Issue
+ ).filter(
+ model.Issue.title.like('%' + str(search_pattern) + '%')
+ ).filter(
+ model.Issue.project_id == repo.id
+ )
+
query = query.order_by(
model.Issue.date_created.desc()
)
diff --git a/pagure/templates/issues.html b/pagure/templates/issues.html
index ec07685..7efe051 100644
--- a/pagure/templates/issues.html
+++ b/pagure/templates/issues.html
@@ -121,6 +121,17 @@
{{ tag.tag }}
{% endfor %}
+
+
+
- {% endif %}
+ {% endif %}
{% if oth_issues %}
From 130ecb363701b8bfadfb91194f04628f8f243e53 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon
Date: Oct 07 2016 21:14:34 +0000
Subject: [PATCH 5/5] No need to rebuild the search query when searching issues
Instead of building a new query, re-use the existing one and adjust it
for the new search criteria.
---
diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py
index 0540e8b..a4e4bbc 100644
--- a/pagure/lib/__init__.py
+++ b/pagure/lib/__init__.py
@@ -1877,12 +1877,8 @@ def search_issues(
)
if search_pattern is not None:
- query = session.query(
- model.Issue
- ).filter(
+ query = query.filter(
model.Issue.title.like('%' + str(search_pattern) + '%')
- ).filter(
- model.Issue.project_id == repo.id
)
query = query.order_by(