This instance will be upgraded to Heptapod 0.26.0rc1 on 2021-10-26 at 14:30 UTC+2 (a few minutes of down time)

Unverified Commit 8b00d01c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Search by issue/mr title and description


Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent edf2d64cd31e
......@@ -20,7 +20,7 @@ def index
terms = params['issue_search']
@issues = issues_filtered
@issues = @issues.where("title LIKE ? OR description LIKE ?", "%#{terms}%", "%#{terms}%") if terms.present?
@issues = @issues.full_search(terms) if terms.present?
@issues = @issues.page(params[:page]).per(20)
assignee_id, milestone_id = params[:assignee_id], params[:milestone_id]
......
......@@ -49,6 +49,10 @@ def search(query)
where("LOWER(title) like :query", query: "%#{query.downcase}%")
end
def full_search(query)
where("LOWER(title) like :query OR LOWER(description) like :query", query: "%#{query.downcase}%")
end
def sort(method)
case method.to_s
when 'newest' then reorder("#{table_name}.created_at DESC")
......
......@@ -177,11 +177,11 @@ def active
joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC")
end
def search query
def search(query)
joins(:namespace).where("projects.archived = ?", false).where("projects.name LIKE :query OR projects.path LIKE :query OR namespaces.name LIKE :query OR projects.description LIKE :query", query: "%#{query}%")
end
def search_by_title query
def search_by_title(query)
where("projects.archived = ?", false).where("LOWER(projects.name) LIKE :query", query: "%#{query.downcase}%")
end
......
......@@ -3,6 +3,9 @@
= link_to [issue.project, issue] do
%span.term.str-truncated= issue.title
.pull-right ##{issue.iid}
.description.term
= preserve do
= search_md_sanitize(markdown(issue.description))
%span.light
#{issue.project.name_with_namespace}
- if issue.closed?
......
......@@ -3,6 +3,9 @@
= link_to [merge_request.target_project, merge_request] do
%span.term.str-truncated= merge_request.title
.pull-right ##{merge_request.iid}
.description.term
= preserve do
= search_md_sanitize(markdown(merge_request.description))
%span.light
#{merge_request.project.name_with_namespace}
.pull-right
......
......@@ -51,11 +51,11 @@ def projects
end
def issues
Issue.where(project_id: limit_project_ids).search(query).order('updated_at DESC')
Issue.where(project_id: limit_project_ids).full_search(query).order('updated_at DESC')
end
def merge_requests
MergeRequest.in_projects(limit_project_ids).search(query).order('updated_at DESC')
MergeRequest.in_projects(limit_project_ids).full_search(query).order('updated_at DESC')
end
def default_scope
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment