Skip to content

Staging#604

Merged
samufacanha2 merged 4 commits intomasterfrom
staging
Mar 9, 2026
Merged

Staging#604
samufacanha2 merged 4 commits intomasterfrom
staging

Conversation

@samufacanha2
Copy link
Contributor

@samufacanha2 samufacanha2 commented Mar 9, 2026

Summary by CodeRabbit

  • New Features

    • Block detail cards now display the timestamp of the last data refresh, providing visibility into data freshness.
  • Bug Fixes

    • Enhanced error handling in API calls to ensure more consistent and reliable data retrieval across the application.
    • Refined asset identifier resolution in transaction processing to improve lookup accuracy.

samufacanha2 and others added 4 commits March 4, 2026 05:39
…tern (#601)

* fix: blocks page stale auto-update, timer drift, and Promise anti-pattern

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: address review findings - consistent error handling, proper type separation

- Fix yesterdayStatisticsCall and totalStatisticsCall to throw on error
  instead of silently returning error string as IBlockStats (was causing
  silent display of zeros on API failures)
- Normalize error messages with typeof guard for non-string errors
- Revert dataUpdatedAt from shared ICard type to local CardContentProps
- Track both queries' dataUpdatedAt using Math.min for accurate staleness
- Remove silent Date.now() fallback, show empty string before first fetch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: prevent rendering bare " ago" before data loads

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* Merge pull request #593 from klever-io/chore/remove-sc-24h-txs

chore: remove sc 24h txs

* Merge pull request #602 from klever-io/fix/nft-precision-tx-list

fix: nft precision tx list

* fix: blocks page stale auto-update, timer drift, and Promise anti-pattern (#601)

* fix: blocks page stale auto-update, timer drift, and Promise anti-pattern

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: address review findings - consistent error handling, proper type separation

- Fix yesterdayStatisticsCall and totalStatisticsCall to throw on error
  instead of silently returning error string as IBlockStats (was causing
  silent display of zeros on API failures)
- Normalize error messages with typeof guard for non-string errors
- Revert dataUpdatedAt from shared ICard type to local CardContentProps
- Track both queries' dataUpdatedAt using Math.min for accurate staleness
- Remove silent Date.now() fallback, show empty string before first fetch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: prevent rendering bare " ago" before data loads

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: David Ianakiara <david@klever.io>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

Walkthrough

This PR refactors data synchronization and error handling across three modules. It introduces timestamp tracking for data freshness in the blocks page by capturing update metadata from queries and deriving a combined update time. It corrects asset precision lookups in transactions by parsing asset IDs. Error handling in API calls is unified to use async/await with standardized error throwing instead of manual Promise construction.

Changes

Cohort / File(s) Summary
Data Age Tracking
src/pages/blocks/index.tsx
Added dataUpdatedAt metadata capture from useQuery calls, computing combined update time as minimum of total and yesterday timestamps. CardContent component extended with dataUpdatedAt prop to display data freshness. Periodic refetch triggers both yesterday and total query updates instead of single refetch.
Asset ID Lookup
src/pages/transactions/index.tsx
Fixed asset precision resolution by splitting assetId on / and using first segment for lookup, narrowing the resolution scope while preserving logic for Claim, BuyOrder, and currencyID paths.
Error Handling Refactor
src/services/apiCalls.ts
Unified error handling across blockCall, yesterdayStatisticsCall, and totalStatisticsCall by replacing manual Promise construction with direct async returns and standardized error throwing. On error conditions, functions now throw errors instead of resolving/returning error values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Poem

🐰 Timestamps now dance in sync so fine,
Old promises we left behind,
Asset IDs split just right,
Data freshness shines so bright,
Errors thrown with cleaner sight!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Staging' is vague and generic, providing no meaningful information about the actual changes in the pull request. Replace with a descriptive title that summarizes the main changes, such as 'Add dataUpdatedAt tracking to block statistics and improve error handling' or 'Update data refresh metadata and error handling across API calls'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch staging

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.46%. Comparing base (03d7c69) to head (28b7c99).
⚠️ Report is 13 commits behind head on master.

Files with missing lines Patch % Lines
src/pages/blocks/index.tsx 0.00% 12 Missing ⚠️
src/services/apiCalls.ts 0.00% 6 Missing ⚠️
src/pages/transactions/index.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           master    #604      +/-   ##
=========================================
- Coverage    0.46%   0.46%   -0.01%     
=========================================
  Files         530     530              
  Lines       20951   20953       +2     
  Branches     5280    4989     -291     
=========================================
  Hits           97      97              
- Misses      20042   20856     +814     
+ Partials      812       0     -812     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/pages/blocks/index.tsx`:
- Around line 148-165: The statistics queries now throw on failure, so update
the useQuery destructuring for both calls (the blocksStatsToday /
isLoadingBlocksStatsToday / refetchTotal / totalUpdatedAt and
blocksStatsYesterday / isLoadingBlocksStatsYesterday / refetchYesterday /
yesterdayUpdatedAt) to also pull isError and error, and change rendering logic
to check isError or data === undefined before falling back — do not use the `||
0` fallback for missing data; instead show an error/placeholder or skip
rendering until data is present so failed fetches don't display fake zeroes.

In `@src/services/apiCalls.ts`:
- Around line 5-18: The function blockCall currently declares its return type as
IBlockResponse but the endpoint returns multiple blocks; change the return type
of the blockCall function signature from IBlockResponse to IBlocksResponse,
update any local references inside blockCall or its callers to expect
data.blocks (IBlock[]) instead of data.block, and ensure the IBlocksResponse
type is imported/available where blockCall is defined so the signature compiles.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f2eb4e94-c9ef-4baa-99da-02a0c880c71e

📥 Commits

Reviewing files that changed from the base of the PR and between 2bbe2ee and 28b7c99.

📒 Files selected for processing (3)
  • src/pages/blocks/index.tsx
  • src/pages/transactions/index.tsx
  • src/services/apiCalls.ts

@samufacanha2 samufacanha2 merged commit 590405a into master Mar 9, 2026
4 of 5 checks passed
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