-
Notifications
You must be signed in to change notification settings - Fork 0
chore(release): dev to main #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,4 +12,4 @@ COPY . . | |
|
|
||
| # Install indexer | ||
| RUN poetry install --no-root | ||
| RUN yarnpkg install | ||
| RUN yarnpkg install | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,4 +39,4 @@ | |
| index_retires() | ||
| # index_proposals() | ||
| index_class_issuers() | ||
| index_votes() | ||
| index_votes() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --! Previous: sha1:a1f8ae0941fd8511e513577d60572126b2525f57 | ||
| --! Hash: sha1:dea81b93fa574159ed977154ed6a84cde77bcc9d | ||
|
|
||
| -- Add transfers view | ||
| -- Solves multi-batch correlation issue by extracting data directly | ||
| -- from the msg.data JSON which preserves the proper credits array structure | ||
| -- One row per unique batch_denom per MsgSend (aggregates duplicate batch_denoms) | ||
|
|
||
| CREATE OR REPLACE VIEW public.transfers AS | ||
| SELECT | ||
| 'regen.ecocredit.v1.EventTransfer'::text AS type, | ||
| SUM( | ||
| CASE | ||
| WHEN credit->>'tradable_amount' = '' THEN 0 | ||
| ELSE (credit->>'tradable_amount')::numeric | ||
| END | ||
| )::text AS tradable_amount, | ||
| SUM( | ||
| CASE | ||
| WHEN credit->>'retired_amount' = '' THEN 0 | ||
| ELSE (credit->>'retired_amount')::numeric | ||
| END | ||
| )::text AS retired_amount, | ||
|
Comment on lines
+12
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The SUM(COALESCE(NULLIF(credit->>'tradable_amount', '')::numeric, 0))::text AS tradable_amount,
SUM(COALESCE(NULLIF(credit->>'retired_amount', '')::numeric, 0))::text AS retired_amount, |
||
| credit->>'batch_denom' AS batch_denom, | ||
| msg.data->>'sender' AS sender, | ||
| msg.data->>'recipient' AS recipient, | ||
| (TRIM(BOTH '"' FROM (tx.data->'tx_response'->'timestamp')::text))::timestamp with time zone AS "timestamp", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The expression for extracting the timestamp can be simplified. Using the (tx.data->'tx_response'->>'timestamp')::timestamp with time zone AS "timestamp", |
||
| msg.block_height, | ||
| msg.chain_num, | ||
| msg.tx_idx, | ||
| msg.msg_idx, | ||
| encode(tx.hash, 'hex') AS tx_hash | ||
| FROM msg | ||
| CROSS JOIN LATERAL jsonb_array_elements(msg.data->'credits') AS credit | ||
| JOIN tx ON | ||
| msg.block_height = tx.block_height | ||
| AND msg.tx_idx = tx.tx_idx | ||
| AND msg.chain_num = tx.chain_num | ||
| WHERE msg.data->>'@type' = '/regen.ecocredit.v1.MsgSend' | ||
| GROUP BY | ||
| credit->>'batch_denom', | ||
| msg.data->>'sender', | ||
| msg.data->>'recipient', | ||
| tx.data->'tx_response'->'timestamp', | ||
| msg.block_height, | ||
| msg.chain_num, | ||
| msg.tx_idx, | ||
| msg.msg_idx, | ||
| tx.hash; | ||
|
|
||
| -- Add indexes on underlying tables for view performance | ||
| CREATE INDEX IF NOT EXISTS msg_data_type_idx ON public.msg USING btree (((data->>'@type'))); | ||
| CREATE INDEX IF NOT EXISTS msg_data_sender_idx ON public.msg USING btree ((data->>'sender')); | ||
| CREATE INDEX IF NOT EXISTS msg_data_recipient_idx ON public.msg USING btree ((data->>'recipient')); | ||
|
Comment on lines
+52
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The CREATE INDEX IF NOT EXISTS msg_data_type_idx ON public.msg USING btree ((data->>'@type'));
CREATE INDEX IF NOT EXISTS msg_data_sender_idx ON public.msg USING btree ((data->>'sender'));
CREATE INDEX IF NOT EXISTS msg_data_recipient_idx ON public.msg USING btree ((data->>'recipient')); |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
CASEonly handles empty strings, butcredit->>'tradable_amount'(and the similarretired_amountexpression) returnsNULLwhen the key is omitted; in that case theELSEbranch castsNULLandSUM(...)can produceNULLfor an entire transfer group instead of0. This can surface as null amounts for valid MsgSend rows where one amount field is absent (e.g., zero-valued proto fields), which breaks consumers that expect numeric strings for both amount columns.Useful? React with 👍 / 👎.