2015-11-26 14:37:03 +05:30
|
|
|
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
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
after_commit :update_project_statistics, on: [:create, :destroy]
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def update_project_statistics
|
|
|
|
ProjectCacheWorker.perform_async(project_id, [], [:lfs_objects_size])
|
|
|
|
end
|
2015-11-26 14:37:03 +05:30
|
|
|
end
|