diff --git a/Gemfile b/Gemfile index a61b1123e90..71579c27889 100644 --- a/Gemfile +++ b/Gemfile @@ -47,8 +47,8 @@ gem "paranoia", "~> 2.2" gem "pdf-forms" # Used in Caseflow Dispatch gem "pdfjs_viewer-rails", git: "https://github.com/senny/pdfjs_viewer-rails.git", ref: "a4249eacbf70175db63b57e9f364d0a9a79e2b43" -#Used to build out PDF files on the backend -#https://github.com/pdfkit/pdfkit +# Used to build out PDF files on the backend +# https://github.com/pdfkit/pdfkit gem "pdfkit" gem "pg", platforms: :ruby # Application server: Puma @@ -61,9 +61,9 @@ gem "rails", "5.2.4.6" gem "rainbow" # React gem "react_on_rails", "11.3.0" +gem "redis-mutex" gem "redis-namespace" gem "redis-rails", "~> 5.0.2" -gem 'redis-mutex' gem "request_store" gem "roo", "~> 2.7" # Use SCSS for stylesheets diff --git a/app/models/end_product_establishment.rb b/app/models/end_product_establishment.rb index 127e448a656..fbc86f7af49 100644 --- a/app/models/end_product_establishment.rb +++ b/app/models/end_product_establishment.rb @@ -9,7 +9,8 @@ # the current status of the EP when the EndProductEstablishment is synced. class EndProductEstablishment < CaseflowRecord - # Using macro-style definition. The locking scope will be TheClass#method and only one method can run at any given time. + # Using macro-style definition. The locking scope will be TheClass + # method and only one method can run at any given time. include RedisMutex::Macro belongs_to :source, polymorphic: true @@ -27,7 +28,8 @@ class EndProductEstablishment < CaseflowRecord # # It is NOT recommended to go below 0.01. (default: 0.1) # :expire => 10 # Specify in seconds when the lock should be considered stale when something went wrong # # with the one who held the lock and failed to unlock. (default: 10) - # auto_mutex :sync!, block: 60, expire: 100, after_failure: lambda { Rails.logger.error('failed to acquire lock! EPE sync is being called by another process. Please try again later.') } + # auto_mutex :sync!, block: 60, expire: 100, after_failure: lambda { Rails.logger.error('failed to acquire lock! + # EPE sync is being called by another process. Please try again later.') } # allow @veteran to be assigned to save upstream calls attr_writer :veteran @@ -59,7 +61,7 @@ def active # We only know the set of inactive EP statuses # We also only know the EP status after fetching it from BGS # Therefore, our definition of active is when the EP is either - # not known or not known to be inactive + # not known or not known to be inactive established.where("synced_status NOT IN (?) OR synced_status IS NULL", EndProduct::INACTIVE_STATUSES) end end @@ -211,23 +213,20 @@ def cancel_unused_end_product! end def sync! - RedisMutex.with_lock("EndProductEstablishment:#{id}", block: 60, expire: 100) do # key => "EndProductEstablishment:id" + RedisMutex.with_lock("EndProductEstablishment:#{id}", block: 60, expire: 100) do + # key => "EndProductEstablishment:id" # There is no need to sync end_product_status if the status # is already inactive since an EP can never leave that state return true unless status_active? - fail EstablishedEndProductNotFound, id unless result # load contentions now, in case "source" needs them. - # this VBMS call is slow and will cause the transaction below - # to timeout in some cases. + # this VBMS call is slow and will cause the transaction below to timeout in some cases. contentions unless result.status_type_code == EndProduct::STATUSES.key("Canceled") transaction do - update!( - synced_status: result.status_type_code, - last_synced_at: Time.zone.now - ) + update!(synced_status: result.status_type_code, + last_synced_at: Time.zone.now) status_cancelled? ? handle_cancelled_ep! : sync_source! close_request_issues_with_no_decision! end @@ -235,7 +234,7 @@ def sync! save_updated_end_product_code! end rescue RedisMutex::LockError - Rails.logger.error('failed to acquire lock! EPE sync is being called by another process. Please try again later.') + Rails.logger.error("failed to acquire lock! EPE sync is being called by another process. Please try again later.") rescue EstablishedEndProductNotFound, AppealRepository::AppealNotValidToReopen => error raise error rescue StandardError => error diff --git a/db/seeds/vbms_ext_claim.rb b/db/seeds/vbms_ext_claim.rb index 3cc0a3f6f4c..e0d25ac3798 100644 --- a/db/seeds/vbms_ext_claim.rb +++ b/db/seeds/vbms_ext_claim.rb @@ -10,6 +10,7 @@ # => removes the audit tables; removes all PriorityEndProductSyncQueue, BatchProcess, and seed records; recreates audit tables # # To destroy the records mentioned above and re-seed, run 'make reseed-vbms-ext-claim' +# Disable :reek:InstanceVariableAssumption module Seeds class VbmsExtClaim < Base @@ -66,8 +67,8 @@ def create_out_of_sync_epes_and_vbms_ext_claims @file_number += 1 end_product_establishment = create_end_product_establishment(:active_hlr_with_cleared_vbms_ext_claim, veteran) - request_issue1 = create_request_issue(:rating, end_product_establishment) - request_issue2 = create_request_issue(:nonrating, end_product_establishment) + created_request_issue_one = create_request_issue(:rating, end_product_establishment) + created_request_issue_two = create_request_issue(:nonrating, end_product_establishment) end # 25 High Level Review, End Product Establishments that have a sync_status of "CAN" and are out_of_sync with @@ -77,8 +78,8 @@ def create_out_of_sync_epes_and_vbms_ext_claims @file_number += 1 end_product_establishment = create_end_product_establishment(:canceled_hlr_with_cleared_vbms_ext_claim, veteran) - request_issue1 = create_request_issue(:rating, end_product_establishment) - request_issue2 = create_request_issue(:nonrating, end_product_establishment) + created_request_issue_one = create_request_issue(:rating, end_product_establishment) + created_request_issue_two = create_request_issue(:nonrating, end_product_establishment) end # 25 Supplemental Claims, End Product Establishments that have a sync_status of "CLR" and are out_of_sync with @@ -88,8 +89,8 @@ def create_out_of_sync_epes_and_vbms_ext_claims @file_number += 1 end_product_establishment = create_end_product_establishment(:cleared_supp_with_canceled_vbms_ext_claim, veteran) - request_issue1 = create_request_issue(:rating, end_product_establishment) - request_issue2 = create_request_issue(:nonrating, end_product_establishment) + created_request_issue_one = create_request_issue(:rating, end_product_establishment) + created_request_issue_two = create_request_issue(:nonrating, end_product_establishment) end # 25 Supplemental Claims, End Product Establishments that have a sync_status of "PEND" and are out_of_sync with @@ -99,8 +100,8 @@ def create_out_of_sync_epes_and_vbms_ext_claims @file_number += 1 end_product_establishment = create_end_product_establishment(:active_supp_with_canceled_vbms_ext_claim, veteran) - request_issue1 = create_request_issue(:rating, end_product_establishment) - request_issue2 = create_request_issue(:nonrating, end_product_establishment) + created_request_issue_one = create_request_issue(:rating, end_product_establishment) + created_request_issue_two = create_request_issue(:nonrating, end_product_establishment) end end @@ -118,8 +119,8 @@ def create_in_sync_epes_and_vbms_ext_claims @file_number += 1 end_product_establishment = create_end_product_establishment(:canceled_hlr_with_canceled_vbms_ext_claim, veteran) - request_issue1 = create_request_issue(:rating, end_product_establishment) - request_issue2 = create_request_issue(:nonrating, end_product_establishment) + created_request_issue_one = create_request_issue(:rating, end_product_establishment) + created_request_issue_two = create_request_issue(:nonrating, end_product_establishment) end # 25 High Level Review, End Product Establishments that have a sync_status of "CLR"" and are in_sync with @@ -129,8 +130,8 @@ def create_in_sync_epes_and_vbms_ext_claims @file_number += 1 end_product_establishment = create_end_product_establishment(:cleared_hlr_with_cleared_vbms_ext_claim, veteran) - request_issue1 = create_request_issue(:rating, end_product_establishment) - request_issue2 = create_request_issue(:nonrating, end_product_establishment) + created_request_issue_one = create_request_issue(:rating, end_product_establishment) + created_request_issue_two = create_request_issue(:nonrating, end_product_establishment) end # 25 Supplemental Claims, End Product Establishments that have a sync_status of "CLR" and are in_sync with @@ -140,8 +141,8 @@ def create_in_sync_epes_and_vbms_ext_claims @file_number += 1 end_product_establishment = create_end_product_establishment(:cleared_supp_with_cleared_vbms_ext_claim, veteran) - request_issue1 = create_request_issue(:rating, end_product_establishment) - request_issue2 = create_request_issue(:nonrating, end_product_establishment) + created_request_issue_one = create_request_issue(:rating, end_product_establishment) + created_request_issue_two = create_request_issue(:nonrating, end_product_establishment) end # 25 Supplemental Claims, End Product Establishments that have a sync_status of "CAN" and are in sync with @@ -151,8 +152,8 @@ def create_in_sync_epes_and_vbms_ext_claims @file_number += 1 end_product_establishment = create_end_product_establishment(:canceled_supp_with_canceled_vbms_ext_claim, veteran) - request_issue1 = create_request_issue(:rating, end_product_establishment) - request_issue2 = create_request_issue(:nonrating, end_product_establishment) + created_request_issue_one = create_request_issue(:rating, end_product_establishment) + created_request_issue_two = create_request_issue(:nonrating, end_product_establishment) end end @@ -177,10 +178,10 @@ def create_vbms_ext_claims_with_no_end_product_establishment # 'trait' will update the following EPE columns: # synced_status, established_at, modifier, code - # additionally, the following records will be created: # an HLR or SC # a VbmsExtClaim + # :reek:FeatureEnvy def create_end_product_establishment(trait, veteran) create(:end_product_establishment, trait, diff --git a/lib/tasks/custom_seed.rake b/lib/tasks/custom_seed.rake index f082fb45e8b..d675dfd842c 100644 --- a/lib/tasks/custom_seed.rake +++ b/lib/tasks/custom_seed.rake @@ -14,11 +14,5 @@ namespace :db do Seeds.const_get(class_name).new.seed! end end - - task :all => :environment do - Dir[File.join(Rails.root, "db", "seeds", "*.rb")].sort.each do |filename| - load(filename) - end - end end end