Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
d0a73c5a
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,体验更适合开发者的 AI 搜索 >>
提交
d0a73c5a
编写于
2月 18, 2015
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'fix-user-page' into 'master'
Fix user page performance See merge request !1543
上级
155b2d46
2f0a764d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
9 deletion
+19
-9
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+10
-7
app/models/user.rb
app/models/user.rb
+9
-2
未找到文件。
app/controllers/users_controller.rb
浏览文件 @
d0a73c5a
...
...
@@ -4,11 +4,8 @@ class UsersController < ApplicationController
layout
:determine_layout
def
show
# Projects user can view
visible_projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
authorized_projects_ids
=
visible_projects
.
pluck
(
:id
)
@contributed_projects
=
Project
.
where
(
id:
authorized_projects_ids
).
@contributed_projects
=
Project
.
where
(
id:
authorized_projects_ids
&
@user
.
contributed_projects_ids
).
in_group_namespace
.
includes
(
:namespace
)
@projects
=
@user
.
personal_projects
.
...
...
@@ -32,8 +29,8 @@ class UsersController < ApplicationController
end
def
calendar
visible_projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
calendar
=
Gitlab
::
CommitsCalendar
.
new
(
visible_
projects
,
@user
)
projects
=
Project
.
where
(
id:
authorized_projects_ids
&
@user
.
contributed_projects_ids
)
calendar
=
Gitlab
::
CommitsCalendar
.
new
(
projects
,
@user
)
@timestamps
=
calendar
.
timestamps
@starting_year
=
calendar
.
starting_year
@starting_month
=
calendar
.
starting_month
...
...
@@ -58,4 +55,10 @@ class UsersController < ApplicationController
return
authenticate_user!
end
end
def
authorized_projects_ids
# Projects user can view
@authorized_projects_ids
||=
ProjectsFinder
.
new
.
execute
(
current_user
).
pluck
(
:id
)
end
end
app/models/user.rb
浏览文件 @
d0a73c5a
...
...
@@ -255,7 +255,7 @@ class User < ActiveRecord::Base
counter
=
0
base
=
username
while
User
.
by_login
(
username
).
present?
||
Namespace
.
by_path
(
username
).
present?
counter
+=
1
counter
+=
1
username
=
"
#{
base
}#{
counter
}
"
end
...
...
@@ -459,7 +459,7 @@ class User < ActiveRecord::Base
def
set_notification_email
if
self
.
notification_email
.
blank?
||
!
self
.
all_emails
.
include?
(
self
.
notification_email
)
self
.
notification_email
=
self
.
email
self
.
notification_email
=
self
.
email
end
end
...
...
@@ -607,4 +607,11 @@ class User < ActiveRecord::Base
def
oauth_authorized_tokens
Doorkeeper
::
AccessToken
.
where
(
resource_owner_id:
self
.
id
,
revoked_at:
nil
)
end
def
contributed_projects_ids
Event
.
where
(
author_id:
self
).
reorder
(
project_id: :desc
).
select
(
'DISTINCT(project_id)'
).
map
(
&
:project_id
)
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录