diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-05-05 01:48:21 +0300 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-05-05 01:48:21 +0300 |
commit | 12fbce2eacdfbbc9bca7f7eaca6e5679ee1aaffd (patch) | |
tree | 055c994736a0408af7c6b4c5ff6ca37ec65c336c /app/models | |
parent | 1bf694fcb95c978e8cf32664b3ced186e7a7d850 (diff) | |
parent | 79dc817183bf1480e72016c3e6a78ac0e57d8c96 (diff) |
Merge branch 'master' into 'add-sentry-js-again-with-vue'
# Conflicts:
# db/schema.rb
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/artifact_blob.rb | 35 | ||||
-rw-r--r-- | app/models/event.rb | 6 | ||||
-rw-r--r-- | app/models/project.rb | 5 | ||||
-rw-r--r-- | app/models/project_wiki.rb | 2 |
4 files changed, 47 insertions, 1 deletions
diff --git a/app/models/ci/artifact_blob.rb b/app/models/ci/artifact_blob.rb new file mode 100644 index 00000000000..b35febc9ac5 --- /dev/null +++ b/app/models/ci/artifact_blob.rb @@ -0,0 +1,35 @@ +module Ci + class ArtifactBlob + include BlobLike + + attr_reader :entry + + def initialize(entry) + @entry = entry + end + + delegate :name, :path, to: :entry + + def id + Digest::SHA1.hexdigest(path) + end + + def size + entry.metadata[:size] + end + + def data + "Build artifact #{path}" + end + + def mode + entry.metadata[:mode] + end + + def external_storage + :build_artifact + end + + alias_method :external_size, :size + end +end diff --git a/app/models/event.rb b/app/models/event.rb index b780c1faf81..e6fad46077a 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -30,6 +30,7 @@ class Event < ActiveRecord::Base # Callbacks after_create :reset_project_activity + after_create :set_last_repository_updated_at, if: :push? # Scopes scope :recent, -> { reorder(id: :desc) } @@ -357,4 +358,9 @@ class Event < ActiveRecord::Base def recent_update? project.last_activity_at > RESET_PROJECT_ACTIVITY_INTERVAL.ago end + + def set_last_repository_updated_at + Project.unscoped.where(id: project_id). + update_all(last_repository_updated_at: created_at) + end end diff --git a/app/models/project.rb b/app/models/project.rb index 025db89ebfd..edbca3b537b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -53,6 +53,11 @@ class Project < ActiveRecord::Base update_column(:last_activity_at, self.created_at) end + after_create :set_last_repository_updated_at + def set_last_repository_updated_at + update_column(:last_repository_updated_at, self.created_at) + end + after_destroy :remove_pages # update visibility_level of forks diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index 70eef359cdd..189c106b70b 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -183,6 +183,6 @@ class ProjectWiki end def update_project_activity - @project.touch(:last_activity_at) + @project.touch(:last_activity_at, :last_repository_updated_at) end end |