Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5f31989a
Commit
5f31989a
authored
Apr 14, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search improved
parent
8dc29896
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
22 deletions
+51
-22
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+4
-2
app/models/issue.rb
app/models/issue.rb
+4
-0
app/models/user.rb
app/models/user.rb
+4
-0
app/views/search/show.html.haml
app/views/search/show.html.haml
+39
-20
No files found.
app/controllers/search_controller.rb
View file @
5f31989a
...
@@ -4,9 +4,11 @@ class SearchController < ApplicationController
...
@@ -4,9 +4,11 @@ class SearchController < ApplicationController
if
query
.
blank?
if
query
.
blank?
@projects
=
[]
@projects
=
[]
@merge_requests
=
[]
@merge_requests
=
[]
@issues
=
[]
else
else
@projects
=
Project
.
search
(
query
).
limit
(
10
)
@projects
=
current_user
.
projects
.
search
(
query
).
limit
(
10
)
@merge_requests
=
MergeRequest
.
search
(
query
).
limit
(
10
)
@merge_requests
=
MergeRequest
.
where
(
:project_id
=>
current_user
.
project_ids
).
search
(
query
).
limit
(
10
)
@issues
=
Issue
.
where
(
:project_id
=>
current_user
.
project_ids
).
search
(
query
).
limit
(
10
)
end
end
end
end
end
end
app/models/issue.rb
View file @
5f31989a
...
@@ -42,6 +42,10 @@ class Issue < ActiveRecord::Base
...
@@ -42,6 +42,10 @@ class Issue < ActiveRecord::Base
opened
.
assigned
(
user
)
opened
.
assigned
(
user
)
end
end
def
self
.
search
query
where
(
"title like :query"
,
:query
=>
"%
#{
query
}
%"
)
end
def
today?
def
today?
Date
.
today
==
created_at
.
to_date
Date
.
today
==
created_at
.
to_date
end
end
...
...
app/models/user.rb
View file @
5f31989a
...
@@ -97,6 +97,10 @@ class User < ActiveRecord::Base
...
@@ -97,6 +97,10 @@ class User < ActiveRecord::Base
def
cared_merge_requests
def
cared_merge_requests
MergeRequest
.
where
(
"author_id = :id or assignee_id = :id"
,
:id
=>
self
.
id
).
opened
MergeRequest
.
where
(
"author_id = :id or assignee_id = :id"
,
:id
=>
self
.
id
).
opened
end
end
def
project_ids
projects
.
map
(
&
:id
)
end
end
end
# == Schema Information
# == Schema Information
#
#
...
...
app/views/search/show.html.haml
View file @
5f31989a
...
@@ -14,27 +14,46 @@
...
@@ -14,27 +14,46 @@
%small
Nothing here
%small
Nothing here
-
else
-
else
-
if
@projects
.
any?
-
if
@projects
.
any?
-
@projects
.
each
do
|
project
|
%h4
Projects
=
link_to
project
do
.padded
%h4
-
@projects
.
each
do
|
project
|
%span
.ico.project
=
link_to
project
do
=
project
.
name
%h4
%small
%span
.ico.project
last activity at
=
project
.
name
=
project
.
last_activity_date
.
stamp
(
"Aug 25, 2011"
)
%small
last activity at
=
project
.
last_activity_date
.
stamp
(
"Aug 25, 2011"
)
-
if
@merge_requests
.
any?
-
if
@merge_requests
.
any?
-
@merge_requests
.
each
do
|
merge_request
|
%h4
Merge Requests
=
link_to
[
merge_request
.
project
,
merge_request
]
do
.padded
%h5
-
@merge_requests
.
each
do
|
merge_request
|
Merge Request
#
=
link_to
[
merge_request
.
project
,
merge_request
]
do
=
merge_request
.
id
%h5
–
Merge Request
#
=
truncate
merge_request
.
title
,
:length
=>
50
=
merge_request
.
id
%small
–
updated at
=
truncate
merge_request
.
title
,
:length
=>
50
=
merge_request
.
updated_at
.
stamp
(
"Aug 25, 2011"
)
%small
%strong
updated at
%span
.label
=
merge_request
.
project
.
name
=
merge_request
.
updated_at
.
stamp
(
"Aug 25, 2011"
)
%strong
%span
.label
=
merge_request
.
project
.
name
-
if
@issues
.
any?
%h4
Issues
.padded
-
@issues
.
each
do
|
issue
|
=
link_to
[
issue
.
project
,
issue
]
do
%h5
Issue
#
=
issue
.
id
–
=
truncate
issue
.
title
,
:length
=>
50
%small
updated at
=
issue
.
updated_at
.
stamp
(
"Aug 25, 2011"
)
%strong
%span
.label
=
issue
.
project
.
name
:javascript
:javascript
$
(
function
()
{
$
(
function
()
{
$
(
"
.search_results
"
).
highlight
(
"
#{
params
[
:search
]
}
"
);
$
(
"
.search_results
"
).
highlight
(
"
#{
params
[
:search
]
}
"
);
...
...
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