diff --git a/benthos/committed_transactions.blobl b/benthos/committed_transactions.blobl index 5355192..857ce51 100644 --- a/benthos/committed_transactions.blobl +++ b/benthos/committed_transactions.blobl @@ -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 })]). @@ -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 })]). @@ -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() } diff --git a/benthos/committed_transactions_test.yaml b/benthos/committed_transactions_test.yaml index 5b0603a..7120b19 100644 --- a/benthos/committed_transactions_test.yaml +++ b/benthos/committed_transactions_test.yaml @@ -41,7 +41,7 @@ tests: - json_equals: [ { "index": { - "_id": "TRANSACTION-foo-test-22", + "_id": "TRANSACTION-test-22", "_index": "ledger" } }, @@ -58,7 +58,8 @@ tests: ], "reference": "", "timestamp": "2022-03-16T13:11:38Z", - "txid": 22 + "txid": 22, + "ledger": "test" }, "indexed": { "amount": [ @@ -83,7 +84,7 @@ tests: }, { "index": { - "_id": "ASSET-foo-test-bank-USD", + "_id": "ASSET-test-bank-USD", "_index": "ledger" } }, @@ -93,6 +94,7 @@ tests: "input": 1000, "name": "USD", "output": 0, + "ledger": "test" }, "indexed": { "name": "USD", @@ -104,7 +106,7 @@ tests: }, { "index": { - "_id": "ASSET-foo-test-world-USD", + "_id": "ASSET-test-world-USD", "_index": "ledger" } }, @@ -114,6 +116,7 @@ tests: "input": 0, "name": "USD", "output": 1000, + "ledger": "test" }, "indexed": { "name": "USD", @@ -125,7 +128,7 @@ tests: }, { "update": { - "_id": "ACCOUNT-foo-test-bank", + "_id": "ACCOUNT-test-bank", "_index": "ledger" } }, @@ -152,7 +155,8 @@ tests: "input": 1000, "output": 0 } - } + }, + "ledger": "test" }, "indexed": { "address": "bank" @@ -164,7 +168,7 @@ tests: }, { "update": { - "_id": "ACCOUNT-foo-test-world", + "_id": "ACCOUNT-test-world", "_index": "ledger" } }, @@ -191,7 +195,8 @@ tests: "input": 0, "output": 1000 } - } + }, + "ledger": "test" }, "indexed": { "address": "world" diff --git a/benthos/saved_metadata.blobl b/benthos/saved_metadata.blobl index b8e1aa2..5e62a3a 100644 --- a/benthos/saved_metadata.blobl +++ b/benthos/saved_metadata.blobl @@ -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 diff --git a/benthos/saved_metadata_test.yaml b/benthos/saved_metadata_test.yaml index 525a447..4ace944 100644 --- a/benthos/saved_metadata_test.yaml +++ b/benthos/saved_metadata_test.yaml @@ -22,7 +22,7 @@ tests: - - json_equals: [{ "update": { - "_id": "TRANSACTION-foo-test-22", + "_id": "TRANSACTION-test-22", "_index": "ledger" } }, @@ -39,7 +39,8 @@ tests: "foo": "bar", "test": "\"quoted-field\"" }, - "volumes": { } + "volumes": { }, + "ledger": "test" }, "indexed": { "address": "22"