Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
c4a9b1132772
Commit
c4a9b113
authored
Apr 12, 2019
by
Ezekiel Kigbo
Browse files
Added sorted_by_stars_asc scope to projects model
parent
fcc0c25f238a
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/models/project.rb
View file @
c4a9b113
...
...
@@ -358,6 +358,7 @@
# last_activity_at is throttled every minute, but last_repository_updated_at is updated with every push
scope
:sorted_by_activity
,
->
{
reorder
(
"GREATEST(COALESCE(last_activity_at, '1970-01-01'), COALESCE(last_repository_updated_at, '1970-01-01')) DESC"
)
}
scope
:sorted_by_stars
,
->
{
reorder
(
star_count: :desc
)
}
scope
:sorted_by_stars_asc
,
->
{
reorder
(
star_count: :asc
)
}
scope
:in_namespace
,
->
(
namespace_ids
)
{
where
(
namespace_id:
namespace_ids
)
}
scope
:personal
,
->
(
user
)
{
where
(
namespace_id:
user
.
namespace_id
)
}
...
...
@@ -545,6 +546,8 @@
reorder
(
last_activity_at: :asc
)
when
'stars_desc'
sorted_by_stars
when
'stars_asc'
sorted_by_stars_asc
else
order_by
(
method
)
end
...
...
Write
Preview
Supports
Markdown
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