Skip to content

Commit

Permalink
Appeals 28984 - fix code climate issues for feature/APPEALS-21351-mer…
Browse files Browse the repository at this point in the history
…ged (#19228)

* init commit - testing code climate fix

* removed method from initialize and add attt_reader

* revert changes of initalizer but added attr_reader :file_number

* removed @file_number and changed request_issue_1

* removed veteran_file_number and just added veteran

* added veteran_file_number back and kept the vet

* removed veteran,left file_number, n removed id

* changes to error string and removed sleep comment

* fixed too many lines, double quotes, and space

* long lines

* remove line to long pepsq line13 had to add lambda

* replacedw/ doublequotes & moved for alphabet order

* removed extra line

* removed sleep comment

* removed sleep comment from caseflowstuckrecordspec

* removed sleep comment populate_end_prod_sync_qu

* removed line to long and ( ) around methods

* ignore line length warn

* re-enable line length

* removed un used code

* disabled FeatureEnvy Smell

* removed comment

* Disabled InstanceVariableAssumption

* Update batch_process_rescue_job.rb

* APPEALS-28984 - uncommented claimant_participant_id & disabled FeatureEnvy for line 185

* moved comments

* add missing comma
  • Loading branch information
Jruuuu authored Aug 24, 2023
1 parent 3885284 commit cda8861
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 38 deletions.
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
23 changes: 11 additions & 12 deletions app/models/end_product_establishment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -211,31 +213,28 @@ 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

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
Expand Down
35 changes: 18 additions & 17 deletions db/seeds/vbms_ext_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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,
Expand Down
6 changes: 0 additions & 6 deletions lib/tasks/custom_seed.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cda8861

Please sign in to comment.