diff --git a/app/models/communication/website/category.rb b/app/models/communication/website/category.rb index e69b1a3adfd36b0235b356ae9894b3c0e7a43e36..6c245b31536df2c6b6c09078b88d6eb489493918 100644 --- a/app/models/communication/website/category.rb +++ b/app/models/communication/website/category.rb @@ -97,6 +97,14 @@ class Communication::Website::Category < ApplicationRecord "admin/communication/websites/categories/static" end + def direct_dependencies + active_storage_blobs + + blocks + + children + + posts + + [parent] + end + def git_dependencies(website) [self, parent].compact + siblings + descendants + active_storage_blobs + posts + website.menus end diff --git a/app/models/communication/website/with_connections.rb b/app/models/communication/website/with_connections.rb index 547a0a0a9ba5742e7c26f3b5d445f81eb1eb1890..c90c7af3d687496ad46feabce95eb501d049f9d7 100644 --- a/app/models/communication/website/with_connections.rb +++ b/app/models/communication/website/with_connections.rb @@ -8,12 +8,14 @@ module Communication::Website::WithConnections through: :connections, source: :object, source_type: 'University::Organization' + + after_save :clean_connections! end def clean_connections! - start = Time.now + # start = Time.now connect self - connections.where('updated_at < ?', time).destroy_all + # connections.where('updated_at < ?', start).destroy_all end def connect(object, source = nil) @@ -40,7 +42,8 @@ module Communication::Website::WithConnections def connect_object(object, source) puts "connect_object #{object} from #{source}" - connections.where(university: university, object: object, source: source).first_or_create + connection = connections.where(university: university, object: object, source: source).first_or_create + connection.touch if connection.persisted? end def disconnect_object(object, source)