QutEcoacoustics / baw-server

The acoustic workbench server for storing and managing ecoacoustic data. Manages the structure and audio data. Provides an API for clients access.
Apache License 2.0
9 stars 4 forks source link

After a site has been deleted mappings fail their validation #618

Open atruskie opened 2 years ago

atruskie commented 2 years ago
irb(main):010:7> Harvest.find(26).harvest_items
irb(main):010:0> Harvest.find(26).harvest_items
=> []
irb(main):011:0> Harvest.find(26).finish!
2022-08-19T04:16:35.534 I [875299:7220 subscriber.rb:149] Rails -- Enqueued BawWorkers::Jobs::Harvest::ScanJob (Job ID: BawWorkers::Jobs::Harvest::ScanJob:id=26) to Resque(harvest_scan_production) -- {:event_name=>"enqueue.active_job", :adapter=>"Resque", :queue=>"harvest_scan_production", :job_class=>"BawWorkers::Jobs::Harvest::ScanJob", :job_id=>"BawWorkers::Jobs::Harvest::ScanJob:id=26", :provider_job_id=>nil, :arguments=>[26]}
2022-08-19T04:16:35.535 I [875299:7220 forwardable.rb:238] BawWorkers -- request -- DELETE https://upload.ecosounds.qut.ecoacoustics.info:8080/api/v2/users/towsey_26
2022-08-19T04:16:35.556 I [875299:7220 forwardable.rb:238] BawWorkers -- response -- Status 200
/usr/local/bundle/gems/aasm-5.3.0/lib/aasm/persistence/active_record_persistence.rb:83:in `aasm_raise_invalid_record': Validation failed: Mappings Site '3260' does not exist for mapping 'Tamar-Wetlands-FL02_3260', Mappings Site '3262' does not exist for mapping 'Tamar-Island-FL01_3262', Mappings Site '3263' does not exist for mapping 'Tamar-Island-FL09_3263', Mappings Site '3264' does not exist for mapping 'Tamar-Wetlands-FL12_3264' (ActiveRecord::RecordInvalid)
atruskie commented 1 year ago

We've seen this again in user facing experience:

An ActiveRecord::RecordInvalid occurred in harvests#show:

  Validation failed: Mappings Site '3694' does not exist for mapping 'BM__R1_B20HR0HI-2_3694', Mappings Site '3740' does not exist for mapping 'SM_R1_UB20HR1-1_3740'
  app/models/harvest.rb:406:in `transition_from_computing_to_review_if_needed!'