summaryrefslogtreecommitdiff
path: root/app/models/lfs_objects_project.rb
blob: b0625c52b62f55a391fff497eed4f922d15385a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class LfsObjectsProject < ActiveRecord::Base
  belongs_to :project
  belongs_to :lfs_object

  validates :lfs_object_id, presence: true
  validates :lfs_object_id, uniqueness: { scope: [:project_id], message: "already exists in project" }
  validates :project_id, presence: true

  after_commit :update_project_statistics, on: [:create, :destroy]

  private

  def update_project_statistics
    ProjectCacheWorker.perform_async(project_id, [], [:lfs_objects_size])
  end
end