Skip to content

Instantly share code, notes, and snippets.

@yoomlam
Created October 4, 2020 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoomlam/551f418bd3af015c79823be6eb4ae28e to your computer and use it in GitHub Desktop.
Save yoomlam/551f418bd3af015c79823be6eb4ae28e to your computer and use it in GitHub Desktop.
Distributed priority cases
# https://github.com/department-of-veterans-affairs/dsva-vacols/issues/149
span=Time.now.last_week.beginning_of_week..Time.now.last_week.end_of_week
=> 2020-09-21 00:00:00 -0400..2020-09-27 23:59:59 -0400
DistributedCase.where(updated_at: span).group(:priority).count
=> {false=>420, true=>1306}
DistributedCase.where(updated_at: span, priority: true).group_by{|dc|
a = dc.send(:ama_docket) ? Appeal.find_by(uuid: dc.case_id) : LegacyAppeal.find_by(vacols_id: dc.case_id)
aod = a&.aod?
cavc = a&.cavc?
next "aod_cavc" if aod and cavc
next "aod" if aod
next "cavc" if cavc
pp("nil_appeal", dc) unless a
next "nil_appeal" unless a
pp("nil", dc)
nil
}.transform_values{|v| v.count}
=> {"aod"=>678, "aod_cavc"=>74, "cavc"=>541, "nil_appeal"=>11, nil=>2}
678 distributed cases were AOD
74 distributed cases were both AOD and CAVC
541 distributed cases were CAVC
11 nil_appeals and 2 nil are mistakes
extracted_case_ids = nil_appeals.map{|i|
DistributedCase.find(i).case_id.sub(/-(attempt|redistributed).*/, '')
}
extracted_case_ids.group_by{|case_id|
a=LegacyAppeal.find_by(vacols_id: case_id)
a=Appeal.find_by(uuid: case_id) unless a
aod = a&.aod?
cavc = a&.cavc?
next "aod_cavc" if aod and cavc
next "aod" if aod
next "cavc" if cavc
pp("nil_appeal", dc) unless a
next "nil_appeal" unless a
pp("nil", dc)
nil
}.transform_values{|v| v.count}
=> {"aod"=>7, "cavc"=>4}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment