2015-10-12 10:42:14 -04:00
|
|
|
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
|
2016-11-22 11:58:10 -05:00
|
|
|
|
2017-06-01 17:36:04 -04:00
|
|
|
after_commit :update_project_statistics, on: [:create, :destroy]
|
2016-11-22 11:58:10 -05:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def update_project_statistics
|
|
|
|
ProjectCacheWorker.perform_async(project_id, [], [:lfs_objects_size])
|
|
|
|
end
|
2015-10-12 10:42:14 -04:00
|
|
|
end
|