dfo-mar-odis / dart

DFO At-sea Reporting Template, collect Elog, CTD and sample data at sea to produce reports then upload to BioChem at the end of the mission
3 stars 1 forks source link

Loading elog and andes events multinet conflict #164

Closed upsonp closed 1 week ago

upsonp commented 1 week ago

A user had started a mission loading events from elog which had created an instrument 'Other - MULTINET', but then later switched to loading events from an Andes report which created the instrument 'Net - multinet'. This caused a conflict

File "C:\DEV\pythonProjects\dart2\core\parsers\andes.py", line 145, in parse_events
    instrument = instruments.get(name__iexact=instrument_name)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\DEV\pythonProjects\dart2\dart_env\Lib\site-packages\django\db\models\query.py", line 640, in get
    raise self.model.MultipleObjectsReturned(
core.models.Instrument.MultipleObjectsReturned: get() returned more than one Instrument -- it returned 2!

To resolve the issue I've added a check to check the instrument type along with the instrument name in the core.parsers.andes.parse_event() function