Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
5f31989a
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5f31989a
编写于
4月 14, 2012
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Search improved
上级
8dc29896
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
51 addition
and
22 deletion
+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
未找到文件。
app/controllers/search_controller.rb
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
]
}
"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录