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
8dc1fae0
Commit
8dc1fae0
authored
Feb 17, 2018
by
Ian Baum
Committed by
Mark Fletcher
Feb 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch 'revert-
215dff76
' into 'master'
Revert "Merge branch 'expired-ci-artifacts' into 'master'" See merge request gitlab-org/gitlab-ce!17193
parent
7db2fc06
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
38 deletions
+4
-38
build.rb
app/models/ci/build.rb
+4
-33
expired-ci-artifacts.yml
changelogs/unreleased/expired-ci-artifacts.yml
+0
-5
No files found.
app/models/ci/build.rb
View file @
8dc1fae0
...
...
@@ -41,41 +41,12 @@ module Ci
scope
:unstarted
,
->
()
{
where
(
runner_id:
nil
)
}
scope
:ignore_failures
,
->
()
{
where
(
allow_failure:
false
)
}
# This convoluted mess is because we need to handle two cases of
# artifact files during the migration. And a simple OR clause
# makes it impossible to optimize.
# Instead we want to use UNION ALL and do two carefully
# constructed disjoint queries. But Rails cannot handle UNION or
# UNION ALL queries so we do the query in a subquery and wrap it
# in an otherwise redundant WHERE IN query (IN is fine for
# non-null columns).
# This should all be ripped out when the migration is finished and
# replaced with just the new storage to avoid the extra work.
scope
:with_artifacts
,
->
()
do
old
=
Ci
::
Build
.
select
(
:id
).
where
(
%q[artifacts_file <> '']
)
new
=
Ci
::
Build
.
select
(
:id
).
where
(
%q[(artifacts_file IS NULL OR artifacts_file = '') AND EXISTS (?)]
,
Ci
::
JobArtifact
.
select
(
1
).
where
(
'ci_builds.id = ci_job_artifacts.job_id'
))
where
(
'ci_builds.id IN (? UNION ALL ?)'
,
old
,
new
)
where
(
'(artifacts_file IS NOT NULL AND artifacts_file <> ?) OR EXISTS (?)'
,
''
,
Ci
::
JobArtifact
.
select
(
1
).
where
(
'ci_builds.id = ci_job_artifacts.job_id'
))
end
scope
:with_artifacts_not_expired
,
->
()
do
old
=
Ci
::
Build
.
select
(
:id
).
where
(
%q[artifacts_file <> '' AND (artifacts_expire_at IS NULL OR artifacts_expire_at > ?)]
,
Time
.
now
)
new
=
Ci
::
Build
.
select
(
:id
).
where
(
%q[(artifacts_file IS NULL OR artifacts_file = '') AND EXISTS (?)]
,
Ci
::
JobArtifact
.
select
(
1
).
where
(
'ci_builds.id = ci_job_artifacts.job_id AND (expire_at IS NULL OR expire_at > ?)'
,
Time
.
now
))
where
(
'ci_builds.id IN (? UNION ALL ?)'
,
old
,
new
)
end
scope
:with_expired_artifacts
,
->
()
do
old
=
Ci
::
Build
.
select
(
:id
).
where
(
%q[artifacts_file <> '' AND artifacts_expire_at < ?]
,
Time
.
now
)
new
=
Ci
::
Build
.
select
(
:id
).
where
(
%q[(artifacts_file IS NULL OR artifacts_file = '') AND EXISTS (?)]
,
Ci
::
JobArtifact
.
select
(
1
).
where
(
'ci_builds.id = ci_job_artifacts.job_id AND expire_at < ?'
,
Time
.
now
))
where
(
'ci_builds.id IN (? UNION ALL ?)'
,
old
,
new
)
end
scope
:with_artifacts_not_expired
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at IS NULL OR artifacts_expire_at > ?'
,
Time
.
now
)
}
scope
:with_expired_artifacts
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at < ?'
,
Time
.
now
)
}
scope
:last_month
,
->
()
{
where
(
'created_at > ?'
,
Date
.
today
-
1
.
month
)
}
scope
:manual_actions
,
->
()
{
where
(
when: :manual
,
status:
COMPLETED_STATUSES
+
[
:manual
])
}
scope
:ref_protected
,
->
{
where
(
protected:
true
)
}
...
...
changelogs/unreleased/expired-ci-artifacts.yml
deleted
100644 → 0
View file @
7db2fc06
---
title
:
Change SQL for expired artifacts to use new ci_job_artifacts.expire_at
merge_request
:
16578
author
:
type
:
performance
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