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-8.1.1 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-8.1.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-8.0.1 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-8.0.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.13.1 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.13.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.12.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.11.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.10.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.9.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.8.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.7.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.6.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.5.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.4.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.3.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.2.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.1.0 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.0.1 app/routines/openstax/accounts/update_group_caches.rb
openstax_accounts-7.0.0 app/routines/openstax/accounts/update_group_caches.rb