BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
56527b63
Commit
56527b63
authored
Aug 13, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ability to search milestones
parent
24b282ae
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
74 additions
and
4 deletions
+74
-4
CHANGELOG
CHANGELOG
+1
-0
search_controller.rb
app/controllers/search_controller.rb
+2
-2
milestone.rb
app/models/milestone.rb
+8
-1
_category.html.haml
app/views/search/_category.html.haml
+14
-0
_milestone.html.haml
app/views/search/results/_milestone.html.haml
+10
-0
search.feature
features/search.feature
+15
-0
search.rb
features/steps/search.rb
+11
-0
search_results.rb
lib/gitlab/search_results.rb
+13
-1
No files found.
CHANGELOG
View file @
56527b63
...
...
@@ -11,6 +11,7 @@ v 8.0.0 (unreleased)
- Allow configuration of import sources for new projects (Artem Sidorenko)
- Search for comments should be case insensetive
- Create cross-reference for closing references on commits pushed to non-default branches (Maël Valais)
- Ability to search milestones
v 7.14.0
- Fix bug where non-project members of the target project could set labels on new merge requests.
...
...
app/controllers/search_controller.rb
View file @
56527b63
...
...
@@ -23,7 +23,7 @@ class SearchController < ApplicationController
@search_results
=
if
@project
unless
%w(blobs notes issues merge_requests wiki_blobs)
.
unless
%w(blobs notes issues merge_requests
milestones
wiki_blobs)
.
include?
(
@scope
)
@scope
=
'blobs'
end
...
...
@@ -36,7 +36,7 @@ class SearchController < ApplicationController
Search
::
SnippetService
.
new
(
current_user
,
params
).
execute
else
unless
%w(projects issues merge_requests)
.
include?
(
@scope
)
unless
%w(projects issues merge_requests
milestones
)
.
include?
(
@scope
)
@scope
=
'projects'
end
Search
::
GlobalService
.
new
(
current_user
,
params
).
execute
...
...
app/models/milestone.rb
View file @
56527b63
...
...
@@ -47,6 +47,13 @@ class Milestone < ActiveRecord::Base
state
:active
end
class
<<
self
def
search
(
query
)
query
=
"%
#{
query
}
%"
where
(
"title like ? or description like ?"
,
query
,
query
)
end
end
def
expired?
if
due_date
due_date
.
past?
...
...
@@ -54,7 +61,7 @@ class Milestone < ActiveRecord::Base
false
end
end
def
open_items_count
self
.
issues
.
opened
.
count
+
self
.
merge_requests
.
opened
.
count
end
...
...
app/views/search/_category.html.haml
View file @
56527b63
...
...
@@ -21,6 +21,13 @@
Merge requests
%span
.badge
=
@search_results
.
merge_requests_count
%li
{
class:
(
"active"
if
@scope
==
'milestones'
)}
=
link_to
search_filter_path
(
scope:
'milestones'
)
do
=
icon
(
'clock-o fw'
)
%span
Milestones
%span
.badge
=
@search_results
.
milestones_count
%li
{
class:
(
"active"
if
@scope
==
'notes'
)}
=
link_to
search_filter_path
(
scope:
'notes'
)
do
=
icon
(
'comments fw'
)
...
...
@@ -74,4 +81,11 @@
Merge requests
%span
.badge
=
@search_results
.
merge_requests_count
%li
{
class:
(
"active"
if
@scope
==
'milestones'
)}
=
link_to
search_filter_path
(
scope:
'milestones'
)
do
=
icon
(
'clock-o fw'
)
%span
Milestones
%span
.badge
=
@search_results
.
milestones_count
app/views/search/results/_milestone.html.haml
0 → 100644
View file @
56527b63
.search-result-row
%h4
=
link_to
[
milestone
.
project
.
namespace
.
becomes
(
Namespace
),
milestone
.
project
,
milestone
]
do
%span
.term.str-truncated
=
milestone
.
title
-
if
milestone
.
description
.
present?
.description.term
=
preserve
do
=
search_md_sanitize
(
markdown
(
milestone
.
description
))
\ No newline at end of file
features/search.feature
View file @
56527b63
...
...
@@ -23,6 +23,13 @@ Feature: Search
Then
I should see
"Foo"
link in the search results
And
I should not see
"Bar"
link in the search results
Scenario
:
I
should see milestones I am looking for
And
project has milestones
When
I search for
"Foo"
When
I click
"Milestones"
link
Then
I should see
"Foo"
link in the search results
And
I should not see
"Bar"
link in the search results
Scenario
:
I
should see project code I am looking for
When
I click project
"Shop"
link
And
I search for
"rspec"
...
...
@@ -44,6 +51,14 @@ Feature: Search
Then
I should see
"Foo"
link in the search results
And
I should not see
"Bar"
link in the search results
Scenario
:
I
should see project milestones
And
project has milestones
When
I click project
"Shop"
link
And
I search for
"Foo"
And
I click
"Milestones"
link
Then
I should see
"Foo"
link in the search results
And
I should not see
"Bar"
link in the search results
Scenario
:
I
should see Wiki blobs
And
project has Wiki content
When
I click project
"Shop"
link
...
...
features/steps/search.rb
View file @
56527b63
...
...
@@ -41,6 +41,12 @@ class Spinach::Features::Search < Spinach::FeatureSteps
end
end
step
'I click "Milestones" link'
do
page
.
within
'.search-filter'
do
click_link
'Milestones'
end
end
step
'I click "Wiki" link'
do
page
.
within
'.search-filter'
do
click_link
'Wiki'
...
...
@@ -72,6 +78,11 @@ class Spinach::Features::Search < Spinach::FeatureSteps
create
(
:merge_request
,
:simple
,
title:
"Bar"
,
source_project:
project
,
target_project:
project
)
end
step
'project has milestones'
do
create
(
:milestone
,
title:
"Foo"
,
project:
project
)
create
(
:milestone
,
title:
"Bar"
,
project:
project
)
end
step
'I should see "Foo" link in the search results'
do
page
.
within
(
'.results'
)
do
find
(
:css
,
'.search-results'
).
should
have_link
'Foo'
...
...
lib/gitlab/search_results.rb
View file @
56527b63
...
...
@@ -19,13 +19,15 @@ module Gitlab
issues
.
page
(
page
).
per
(
per_page
)
when
'merge_requests'
merge_requests
.
page
(
page
).
per
(
per_page
)
when
'milestones'
milestones
.
page
(
page
).
per
(
per_page
)
else
Kaminari
.
paginate_array
([]).
page
(
page
).
per
(
per_page
)
end
end
def
total_count
@total_count
||=
projects_count
+
issues_count
+
merge_requests_count
@total_count
||=
projects_count
+
issues_count
+
merge_requests_count
+
milestones_count
end
def
projects_count
...
...
@@ -40,6 +42,10 @@ module Gitlab
@merge_requests_count
||=
merge_requests
.
count
end
def
milestones_count
@milestones_count
||=
milestones
.
count
end
def
empty?
total_count
.
zero?
end
...
...
@@ -60,6 +66,12 @@ module Gitlab
issues
.
order
(
'updated_at DESC'
)
end
def
milestones
milestones
=
Milestone
.
where
(
project_id:
limit_project_ids
)
milestones
=
milestones
.
search
(
query
)
milestones
.
order
(
'updated_at DESC'
)
end
def
merge_requests
merge_requests
=
MergeRequest
.
in_projects
(
limit_project_ids
)
if
query
=~
/[#!](\d+)\z/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment