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
b6de7ad4
Unverified
Commit
b6de7ad4
authored
Sep 18, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 500 on trending projects if isntance has 100k+ projects
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
0aec0d53
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
14 deletions
+5
-14
trending_projects_finder.rb
app/finders/trending_projects_finder.rb
+4
-13
_list.html.haml
app/views/shared/projects/_list.html.haml
+1
-1
No files found.
app/finders/trending_projects_finder.rb
View file @
b6de7ad4
...
...
@@ -2,21 +2,12 @@ class TrendingProjectsFinder
def
execute
(
current_user
,
start_date
=
nil
)
start_date
||=
Date
.
today
-
1
.
month
projects
=
projects_for
(
current_user
)
# Determine trending projects based on comments count
# for period of time - ex. month
trending_project_ids
=
Note
.
select
(
"notes.project_id, count(notes.project_id) as pcount"
).
where
(
'notes.created_at > ?'
,
start_date
).
group
(
"project_id"
).
reorder
(
"pcount DESC"
).
map
(
&
:project_id
)
sql_order_ids
=
trending_project_ids
.
reverse
.
map
{
|
project_id
|
"id =
#{
project_id
}
"
}.
join
(
", "
)
# Get list of projects that user allowed to see
projects
=
projects_for
(
current_user
)
projects
.
where
(
id:
trending_project_ids
).
reorder
(
sql_order_ids
)
projects
.
joins
(
:notes
).
where
(
'notes.created_at > ?'
,
start_date
).
group
(
"projects.id"
).
reorder
(
"count(notes.id) DESC"
)
end
private
...
...
app/views/shared/projects/_list.html.haml
View file @
b6de7ad4
...
...
@@ -8,7 +8,7 @@
=
render
"shared/projects/project"
,
project:
project
,
avatar:
avatar
,
stars:
stars
,
css_class:
css_class
-
if
projects
.
count
>
projects_limit
-
if
projects
.
size
>
projects_limit
%li
.bottom.center
.light
#{
projects_limit
}
of
#{
pluralize
(
projects
.
count
,
'project'
)
}
displayed.
...
...
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