diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-11-30 14:19:07 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-12-03 12:04:49 +0100 |
commit | 8f01e67980d4ab8a7879800156cdc1dee07a4e8b (patch) | |
tree | e2b15852db7663163e7f88d6aa6a44498379b167 /app | |
parent | 2045a771bfa5a1a32ff04f5bc23d58f1170b6359 (diff) | |
download | gitlab-ce-8f01e67980d4ab8a7879800156cdc1dee07a4e8b.tar.gz |
Revert "Rename `job_archive|metadata` to `artifacts_archive|metadata`"
This reverts commit 714082e65304ae2ec5c5400c59a68ab63e724aa9.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/build.rb | 4 | ||||
-rw-r--r-- | app/models/concerns/artifact_migratable.rb | 16 | ||||
-rw-r--r-- | app/models/project_statistics.rb | 3 |
3 files changed, 10 insertions, 13 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 842323e26e3..91747da28a1 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -16,8 +16,8 @@ module Ci has_many :trace_sections, class_name: 'Ci::BuildTraceSection' has_many :job_artifacts, class_name: 'Ci::JobArtifact', foreign_key: :job_id, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent - has_one :artifacts_archive, -> () { where(file_type: Ci::JobArtifact.file_types[:archive]) }, class_name: 'Ci::JobArtifact', foreign_key: :job_id - has_one :artifacts_metadata, -> () { where(file_type: Ci::JobArtifact.file_types[:metadata]) }, class_name: 'Ci::JobArtifact', foreign_key: :job_id + has_one :job_archive, -> () { where(file_type: Ci::JobArtifact.file_types[:archive]) }, class_name: 'Ci::JobArtifact', foreign_key: :job_id + has_one :job_metadata, -> () { where(file_type: Ci::JobArtifact.file_types[:metadata]) }, class_name: 'Ci::JobArtifact', foreign_key: :job_id # The "environment" field for builds is a String, and is the unexpanded name def persisted_environment diff --git a/app/models/concerns/artifact_migratable.rb b/app/models/concerns/artifact_migratable.rb index b99585a0b65..811a8252459 100644 --- a/app/models/concerns/artifact_migratable.rb +++ b/app/models/concerns/artifact_migratable.rb @@ -3,11 +3,11 @@ # Meant to be prepended so the interface can stay the same module ArtifactMigratable def artifacts_file - artifacts_archive&.file || legacy_artifacts_file + job_archive&.file || legacy_artifacts_file end def artifacts_metadata - artifacts_metadata&.file || legacy_artifacts_metadata + job_metadata&.file || legacy_artifacts_metadata end def artifacts? @@ -19,20 +19,20 @@ module ArtifactMigratable end def artifacts_file_changed? - artifacts_archive&.file_changed? || attribute_changed?(:artifacts_file) + job_archive&.file_changed? || attribute_changed?(:artifacts_file) end def remove_artifacts_file! - if artifacts_archive - artifacts_archive.destroy + if job_archive + job_archive.destroy else remove_legacy_artifacts_file! end end def remove_artifacts_metadata! - if artifacts_metadata - artifacts_metadata.destroy + if job_metadata + job_metadata.destroy else remove_legacy_artifacts_metadata! end @@ -40,6 +40,6 @@ module ArtifactMigratable def artifacts_size read_attribute(:artifacts_size).to_i + - artifacts_archive&.size.to_i + artifacts_metadata&.size.to_i + job_archive&.size.to_i + job_metadata&.size.to_i end end diff --git a/app/models/project_statistics.rb b/app/models/project_statistics.rb index b3d4c82583c..17b9d2cf7b4 100644 --- a/app/models/project_statistics.rb +++ b/app/models/project_statistics.rb @@ -35,9 +35,6 @@ class ProjectStatistics < ActiveRecord::Base end def update_build_artifacts_size - # REMARK: - # We perform dual calculation as we run SQL query: sum does not instantiate AR model. - # The Ci::Build#artifacts_size returns sum of ci_builds.artifacts_size and ci_job_artifacts.file_size self.build_artifacts_size = project.builds.sum(:artifacts_size) + Ci::JobArtifact.artifacts_size_for(self) |