Skip to content

Commit

Permalink
feat: Add 'ledger' property inside indexed documents data.
Browse files Browse the repository at this point in the history
This allow the frontend to make cross ledger requests and know on which ledger transactions are.
  • Loading branch information
gfyrag committed Aug 19, 2022
1 parent ddac46e commit c4cdf99
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions benthos/committed_transactions.blobl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ map committedTransactions {
"_index": env("OPENSEARCH_INDEX"),
"_id": "TRANSACTION-%s-%s".format(this.ledger, t.data.txid)
}
}, t.merge({
}, t.assign({"data": {"ledger": this.ledger}}).merge({
"when": this.date,
"ledger": this.ledger
})]).
Expand All @@ -91,7 +91,7 @@ map committedTransactions {
"_index": env("OPENSEARCH_INDEX"),
"_id": "ASSET-%s-%s-%s".format(this.ledger, t.data.account, t.data.name)
}
}, t.merge({
}, t.assign({"data": {"ledger": this.ledger}}).merge({
"when": this.date,
"ledger": this.ledger
})]).
Expand All @@ -109,7 +109,7 @@ map committedTransactions {
"_index": env("OPENSEARCH_INDEX"),
"_id": "ACCOUNT-%s-%s".format(this.ledger, t.upsert.data.address)
}
}, t]).
}, t.assign({"upsert": {"data": {"ledger": this.ledger}}})]).
flatten(),
].flatten()
}
Expand Down
11 changes: 8 additions & 3 deletions benthos/committed_transactions_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ tests:
],
"reference": "",
"timestamp": "2022-03-16T13:11:38Z",
"txid": 22
"txid": 22,
"ledger": "test"
},
"indexed": {
"amount": [
Expand Down Expand Up @@ -93,6 +94,7 @@ tests:
"input": 1000,
"name": "USD",
"output": 0,
"ledger": "test"
},
"indexed": {
"name": "USD",
Expand All @@ -114,6 +116,7 @@ tests:
"input": 0,
"name": "USD",
"output": 1000,
"ledger": "test"
},
"indexed": {
"name": "USD",
Expand Down Expand Up @@ -152,7 +155,8 @@ tests:
"input": 1000,
"output": 0
}
}
},
"ledger": "test"
},
"indexed": {
"address": "bank"
Expand Down Expand Up @@ -191,7 +195,8 @@ tests:
"input": 0,
"output": 1000
}
}
},
"ledger": "test"
},
"indexed": {
"address": "world"
Expand Down
3 changes: 2 additions & 1 deletion benthos/saved_metadata.blobl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ map savedMetadata {
"address": this.payload.targetId,
"volumes": {},
"balances": {},
"metadata": this.payload.metadata
"metadata": this.payload.metadata,
"ledger": this.ledger
},
"indexed": {
"address": this.payload.targetId
Expand Down
5 changes: 3 additions & 2 deletions benthos/saved_metadata_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tests:
-
- json_equals: [{
"update": {
"_id": "TRANSACTION-foo-test-22",
"_id": "TRANSACTION-test-22",
"_index": "ledger"
}
},
Expand All @@ -39,7 +39,8 @@ tests:
"foo": "bar",
"test": "\"quoted-field\""
},
"volumes": { }
"volumes": { },
"ledger": "test"
},
"indexed": {
"address": "22"
Expand Down

0 comments on commit c4cdf99

Please sign in to comment.