Skip to content

Commit

Permalink
Merge pull request #183 from pixlise/feature/bug-roi-updating
Browse files Browse the repository at this point in the history
ROI Updating and Selection Bugs
  • Loading branch information
RyanStonebraker authored Mar 18, 2024
2 parents a856634 + b97f569 commit 75e380a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/ws/handlers/roi.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func updateROI(roi *protos.ROIItem, hctx wsHelpers.HandlerContext) (*protos.ROII
// Once created, these can't be set to empty
if roi.ScanEntryIndexesEncoded != nil && !utils.SlicesEqual(dbItem.ScanEntryIndexesEncoded, roi.ScanEntryIndexesEncoded) {
dbItem.ScanEntryIndexesEncoded = roi.ScanEntryIndexesEncoded
update = append(update, bson.E{Key: "ScanEntryIndexesEncoded", Value: roi.ScanEntryIndexesEncoded})
update = append(update, bson.E{Key: "scanentryindexesencoded", Value: roi.ScanEntryIndexesEncoded})
}

// Once created, these can't be set to empty
Expand Down Expand Up @@ -310,7 +310,7 @@ func updateROI(roi *protos.ROIItem, hctx wsHelpers.HandlerContext) (*protos.ROII
}

if result.MatchedCount != 1 {
hctx.Svcs.Log.Errorf("ROI UpdateByID result had unexpected counts %+v id: %v", result, roi.Id)
hctx.Svcs.Log.Errorf("ROI UpdateByID result had unexpected counts %v id: %v", result, roi.Id)
}

// Return the merged item we validated, which in theory is in the DB now
Expand Down
5 changes: 3 additions & 2 deletions api/ws/handlers/selection-entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ func writeSelection(id string, idxs *protos.ScanEntryRange, db *mongo.Database,
return err
}

if dbResult.UpsertedCount != 1 && dbResult.ModifiedCount != 1 {
logger.Errorf("writeSelection UpdateByID result had unexpected counts %+v", dbResult)
// Modified and Upsert counts will be 0 if the selection hasn't changed, so we just check matched
if dbResult.MatchedCount != 1 {
logger.Errorf("writeSelection (%v) UpdateByID result had unexpected counts %+v", id, dbResult)
}

return nil
Expand Down

0 comments on commit 75e380a

Please sign in to comment.