Skip to content

chore(release): dev to main#69

Open
S4mmyb wants to merge 1 commit intomainfrom
dev
Open

chore(release): dev to main#69
S4mmyb wants to merge 1 commit intomainfrom
dev

Conversation

@S4mmyb
Copy link
Member

@S4mmyb S4mmyb commented Mar 4, 2026

indexing credit transfers

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the indexing capabilities of the application, specifically for credit transfers. It introduces a new database view to streamline data extraction and correlation, along with additional indexes to optimize query performance. The changes aim to improve the efficiency and reliability of data retrieval related to credit transfers.

Highlights

  • Credit Transfers Indexing: This pull request introduces indexing for credit transfers to improve data retrieval and correlation.
  • Database View Creation: A new database view public.transfers is created to extract and structure credit transfer data directly from JSON message data.
  • Indexing Optimization: Additional indexes are added to the msg table to enhance the performance of the new transfers view.
Changelog
  • docker/indexer.Dockerfile
    • Updated dependencies with yarnpkg install.
  • main.py
    • Ensured index_votes() is called during indexing.
  • migrations/committed/000008.sql
    • Added a new database view public.transfers for indexing credit transfers and created indexes on the underlying tables for performance.
  • migrations/schema_snapshot.sql
    • Updated the schema snapshot to include the new transfers view and associated indexes.
Activity
  • S4mmyb authored the pull request with the title 'chore(release): dev to main' and the description 'indexing credit transfers'.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new SQL migration to index credit transfers. This is achieved by creating a new view named transfers and adding several indexes to the msg table to improve query performance. My review focuses on the new migration file, offering suggestions to improve the SQL for better readability and maintainability.

Comment on lines +12 to +23
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,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The CASE statements used to handle empty strings for tradable_amount and retired_amount can be simplified. Using COALESCE with NULLIF is a more concise and idiomatic way to achieve the same result in SQL, which improves code readability.

  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",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The expression for extracting the timestamp can be simplified. Using the ->> operator will extract the JSON field as text directly, which removes the need for an explicit cast to text and the subsequent TRIM function call.

  (tx.data->'tx_response'->>'timestamp')::timestamp with time zone AS "timestamp",

Comment on lines +52 to +54
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'));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The CREATE INDEX statements contain redundant parentheses around the index expressions. While this is valid syntax, it harms readability. For an expression index, the syntax is ((expression)), but here it is (((expression))). Removing the extra pair of parentheses will make the code cleaner.

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'));

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d45e9c69e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +14 to +15
WHEN credit->>'tradable_amount' = '' THEN 0
ELSE (credit->>'tradable_amount')::numeric

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat missing amount fields as zero in transfers view

The CASE only handles empty strings, but credit->>'tradable_amount' (and the similar retired_amount expression) returns NULL when the key is omitted; in that case the ELSE branch casts NULL and SUM(...) can produce NULL for an entire transfer group instead of 0. 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 👍 / 👎.

Copy link
Member

@blushi blushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like comments from AI review are mostly about syntax simplification, I guess it's fine to leave as is now that's on dev so approving

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants