Skip to content

Conversation

@pauldelucia
Copy link
Member

@pauldelucia pauldelucia commented Oct 17, 2024

The function insert_name_contests_as_normalized_names was returning only names that have not been updated for over an hour, and these names were being used to update the UI showing the contest states. But on testnet, contests only last one hour. So the votes for those names were not being displayed. So instead, we check the network and if it's testnet, we only update the contests created in the past hour, and on mainnet, created in the past two weeks.

Also, in registering dpns names, display aliases instead of identifiers.

Summary by CodeRabbit

  • New Features

    • Streamlined identity selection process for registering DPNS names, enhancing user experience.
    • Improved handling of contested names in the database, ensuring better data integrity and clarity.
  • Bug Fixes

    • Enhanced logic for updating contested names and contestants, preventing potential data inconsistencies.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 17, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces modifications to the Database struct and the RegisterDpnsNameScreen struct. Key enhancements include improved methods for managing contested names, ensuring data integrity during updates, and refining the identity selection process in the UI. Notably, the get_contested_names method now supports network-specific operations, while the insert_name_contests_as_normalized_names method has been updated to better handle name updates based on network conditions. The UI changes streamline how identities are displayed and selected, maintaining overall control flow.

Changes

File Path Change Summary
src/database/contested_names.rs - Enhanced get_contested_names to handle Network type and populate a hashmap with ContestedName objects.
- Refined insert_or_update_name_contest logic for contested name existence checks.
- Updated insert_or_update_contenders with transaction logic.
- Renamed outdated_names to names_to_be_updated in insert_name_contests_as_normalized_names and expanded update logic based on network type.
- Updated update_ending_time to ensure new value checks.
src/ui/identities/register_dpns_name_screen.rs - Simplified render_identity_id_selection to use QualifiedIdentity alias directly, with fallback to Base58 encoding for identity ID.
- Maintained logic in register_dpns_name_clicked while utilizing the modified identity selection process.

Possibly related PRs

  • feat: register usernames #3: The changes in this PR involve the registration of DPNS usernames, which is directly related to the modifications in the RegisterDpnsNameScreen struct and methods in the main PR, as both involve handling DPNS names and user identity selection processes.

Poem

In the database deep, where names do contest,
New logic emerges, ensuring the best.
With identities clear, and selections so bright,
We streamline the process, making it right.
Hop along, dear friends, let’s celebrate this feat,
For every contested name, we make it complete! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
src/ui/identities/register_dpns_name_screen.rs (1)

70-72: LGTM! Consider a minor readability improvement.

The changes simplify the display logic for identity selection, which aligns with the AI summary's description of streamlining the process. The code now correctly uses the alias if available, falling back to the identity ID if not.

For improved readability, consider extracting the display text logic into a separate method:

 ui.selectable_value(
     &mut self.selected_qualified_identity,
     Some(qualified_identity.clone()),
-    qualified_identity.alias.as_ref().unwrap_or(
-        &qualified_identity.identity.id().to_string(Encoding::Base58),
-    ),
+    self.get_identity_display_text(qualified_identity),
 )

+ // Add this method to the impl block
+ fn get_identity_display_text(&self, qualified_identity: &QualifiedIdentity) -> String {
+     qualified_identity.alias.clone().unwrap_or_else(|| 
+         qualified_identity.identity.id().to_string(Encoding::Base58)
+     )
+ }

This change would make the main logic more concise and easier to understand at a glance.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 601d405 and dc23dab.

📒 Files selected for processing (2)
  • src/database/contested_names.rs (4 hunks)
  • src/ui/identities/register_dpns_name_screen.rs (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
src/ui/identities/register_dpns_name_screen.rs (1)

Line range hint 1-190: Verify alignment with PR objectives

The changes in this file focus on improving the identity selection display logic, which is a positive enhancement. However, these modifications don't appear to address the stated PR objectives of fixing "active contest vote tallies not being updated with refresh button".

To ensure we're not missing any relevant changes, please run the following script:

This script will help us verify if there are any other files in the codebase that might contain the changes related to the PR objectives. If no results are found, we may need to clarify the scope of the PR with the author.

src/database/contested_names.rs (1)

464-464: Verify handling of None timestamps when sorting

When sorting names_to_be_updated, the code uses a.1.unwrap_or(0), assigning a timestamp of 0 to entries where last_updated is None. This causes these entries to be considered the oldest. If this is intentional and you want entries with no last_updated to appear first, please confirm. Otherwise, consider using a more appropriate default value or adjusting the sorting logic to ensure correct ordering.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@QuantumExplorer QuantumExplorer merged commit 924b51d into master Oct 19, 2024
1 check was pending
@QuantumExplorer QuantumExplorer deleted the fix/refresh-vote-counts branch October 19, 2024 21:06
@coderabbitai coderabbitai bot mentioned this pull request Dec 13, 2024
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.

3 participants