Sha256: ef852df089e55c98c8e8939c325700a9f8570c5ce77c9410461e33d37832ade4

Contents?: true

Size: 791 Bytes

Versions: 48

Compression:

Stored size: 791 Bytes

Contents

# Routine for updating group caches when a group_nesting is created or destroyed
#
# Caller provides the group_nesting object

module OpenStax
  module Accounts

    class UpdateGroupCaches

      # This transaction needs :repeatable_read to prevent missed updates
      lev_routine transaction: :repeatable_read

      protected

      def exec(group_nesting)
        subtree_group_ids = group_nesting.member_group.subtree_group_ids
        supertree_group_ids = group_nesting.container_group.supertree_group_ids
        tree_group_ids = (subtree_group_ids + supertree_group_ids).uniq

        Group.where(id: subtree_group_ids).update_all(cached_supertree_group_ids: nil)
        Group.where(id: supertree_group_ids).update_all(cached_subtree_group_ids: nil)
      end

    end

  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
openstax_accounts-6.4.2 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.4.1 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.4.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.3.2 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.3.1 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.3.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.2.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.1.7 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.1.6 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.1.5 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.1.4 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.1.3 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.1.2 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.1.1 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.1.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-6.0.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-5.2.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-5.1.2 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-5.1.1 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-5.1.0 app/routines/openstax/accounts/update_group_caches.rb