forked from tangled.org/core
this repo has no description

appview/models: fix logic issue when converting label record -> label ops

the ordering of ops should be deletes first followed by additions, in
order for ingestions to be idempotent. after every optimistic update the
the DB, we ingest the same record via the firehose. an ordering
difference resulted in certain additions being marked as no-ops when in
reality, it should be an addition followed by a deletion.

Signed-off-by: oppiliappan <me@oppi.li>

Changed files
+5 -4
appview
models
+5 -4
appview/models/label.go
···
}
var ops []LabelOp
-
for _, o := range record.Add {
if o != nil {
op := mkOp(o)
-
op.Operation = LabelOperationAdd
ops = append(ops, op)
}
}
-
for _, o := range record.Delete {
if o != nil {
op := mkOp(o)
-
op.Operation = LabelOperationDel
ops = append(ops, op)
}
}
···
}
var ops []LabelOp
+
// deletes first, then additions
+
for _, o := range record.Delete {
if o != nil {
op := mkOp(o)
+
op.Operation = LabelOperationDel
ops = append(ops, op)
}
}
+
for _, o := range record.Add {
if o != nil {
op := mkOp(o)
+
op.Operation = LabelOperationAdd
ops = append(ops, op)
}
}