Monorepo for Tangled tangled.org

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

merged opened by oppi.li targeting master from push-plpuqtyrprou

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

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:qfpnj4og54vl56wngdriaxug/sh.tangled.repo.pull/3lzqfzwoi5h22
+5 -4
Diff #0
+5 -4
appview/models/label.go
··· 232 232 } 233 233 234 234 var ops []LabelOp 235 - for _, o := range record.Add { 235 + // deletes first, then additions 236 + for _, o := range record.Delete { 236 237 if o != nil { 237 238 op := mkOp(o) 238 - op.Operation = LabelOperationAdd 239 + op.Operation = LabelOperationDel 239 240 ops = append(ops, op) 240 241 } 241 242 } 242 - for _, o := range record.Delete { 243 + for _, o := range record.Add { 243 244 if o != nil { 244 245 op := mkOp(o) 245 - op.Operation = LabelOperationDel 246 + op.Operation = LabelOperationAdd 246 247 ops = append(ops, op) 247 248 } 248 249 }

History

1 round 0 comments
sign up or login to add to the discussion
oppi.li submitted #0
1 commit
expand
appview/models: fix logic issue when converting label record -> label ops
expand 0 comments
pull request successfully merged