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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
fba2ec45
Commit
fba2ec45
authored
Jul 19, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just use order(id: :desc) for latest stuffs:
We don't need that subquery for group by ref and alike here.
parent
1a41cb90
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
11 deletions
+3
-11
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+1
-9
app/models/project.rb
app/models/project.rb
+1
-1
No files found.
app/models/ci/build.rb
View file @
fba2ec45
...
...
@@ -16,7 +16,7 @@ module Ci
scope
:with_expired_artifacts
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at < ?'
,
Time
.
now
)
}
scope
:last_month
,
->
()
{
where
(
'created_at > ?'
,
Date
.
today
-
1
.
month
)
}
scope
:latest_success_with_artifacts
,
->
()
do
with_artifacts
.
success
.
latest
with_artifacts
.
success
.
order
(
id: :desc
)
end
mount_uploader
:artifacts_file
,
ArtifactUploader
...
...
app/models/ci/pipeline.rb
View file @
fba2ec45
...
...
@@ -20,14 +20,6 @@ module Ci
after_touch
:update_state
after_save
:keep_around_commits
scope
:latest
,
->
do
max_id
=
unscope
(
:select
).
select
(
"max(
#{
table_name
}
.id)"
).
group
(
:ref
)
where
(
id:
max_id
)
end
def
self
.
truncate_sha
(
sha
)
sha
[
0
...
8
]
end
...
...
@@ -226,7 +218,7 @@ module Ci
def
keep_around_commits
return
unless
project
project
.
repository
.
keep_around
(
self
.
sha
)
project
.
repository
.
keep_around
(
self
.
before_sha
)
end
...
...
app/models/project.rb
View file @
fba2ec45
...
...
@@ -431,7 +431,7 @@ class Project < ActiveRecord::Base
# ref can't be HEAD or SHA, can only be branch/tag name
def
latest_success_pipeline_for
(
ref
=
'master'
)
pipelines
.
where
(
ref:
ref
).
success
.
latest
pipelines
.
where
(
ref:
ref
).
success
.
order
(
id: :desc
)
end
# ref can't be HEAD or SHA, can only be branch/tag name
...
...
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