Closed ttavenner closed 8 years ago
Discovered that this bug was actually caused by the use of TakeFirst() in the vendor and inspection loaders. It was converting the inspection and violation arrays into single objects. THe solution is to apply TakeFirst() individually to each field where I want it to apply and not apply it to arrays.
Normally each vendor document contains an array of inspection objects. There is a small bug right now where occasionally instead of an array, this will be a single inspection object. I believe this happens when a vendor has only one inspection on file. Similarly, if a vendor has zero inspections on file the inspections array doesn't exist on the vendor record. These two items can cause problems downstream for the scoring functionality and the API.
The fix, I believe, is to make sure that an empty
inspections
array is added when the vendor record is first created. This might mean separating the vendor update from the vendor create steps in the pipeline rather than using an upsert method to avoid overwriting the existing inspections array.