Skip to content

Blocks page '24h' stats show yesterday's calendar day, not rolling 24h window #596

@ianakiara

Description

@ianakiara

Summary

The blocks page (/blocks) displays three stat cards labeled "Blocks 24h", "Rewards 24h", and "Burned 24h". These labels imply a rolling 24-hour window from the current moment, but the data actually represents yesterday's completed calendar day (midnight-to-midnight).

Evidence

1. Frontend calls yesterdayStatisticsCall()

File: src/services/apiCalls.ts

export const yesterdayStatisticsCall = async (): Promise<IBlockStats> => {
  const res = await api.get({
    route: 'block/statistics-by-day/1',
  });
  return res.data.block_stats_by_day[0];
};

The function is explicitly named yesterdayStatisticsCall, and it hits block/statistics-by-day/1.

2. API endpoint returns calendar-day buckets

The upstream Klever API endpoint block/statistics-by-day/{N} returns N discrete calendar-day records, each with a date field (Unix timestamp for that day). The {N} parameter is the number of past days to return — not a rolling hour window.

Confirmed by the charts page (src/pages/charts/index.tsx), which calls block/statistics-by-day/15 and formats each record's date as:

date: format(stats.date, 'dd MMM')  // e.g., "05 Mar"

This proves each record maps to a specific calendar date, not a sliding time window.

3. UI labels are misleading

File: src/pages/blocks/index.tsx (lines 189-247)

const cards: ICard[] = [
  {
    title: 'Number of Blocks',
    headers: ['Blocks 24h', 'Cumulative Number'],       // ← misleading
    values: [blocksStatsYesterday?.totalBlocks, ...],
  },
  {
    title: 'Block Reward',
    headers: ['Rewards 24h', 'Cumulative Revenue'],      // ← misleading
    values: [blocksStatsYesterday?.totalBlockRewards, ...],
  },
  {
    title: 'Stats on Burned KLV',
    headers: ['Burned 24h', 'Burned in Total'],           // ← misleading
    values: [blocksStatsYesterday?.totalBurned, ...],
  },
];

All three cards use blocksStatsYesterday (from yesterdayStatisticsCall) but label the values as "24h".

4. No rolling 24h endpoint exists

The upstream Klever API only exposes:

  • block/statistics-by-day/{N} — calendar-day buckets
  • block/statistics-total/0 — all-time cumulative totals

There is no block/statistics-rolling/24h or time-range-based block statistics endpoint.

Impact

Users see "Blocks 24h" / "Rewards 24h" / "Burned 24h" and expect data from the last 24 hours. Instead, they get yesterday's full-day stats, which can be up to ~48 hours stale (e.g., at 11:59 PM, the data still reflects the day before).

Options

  1. Fix the label — Rename "24h" → "Yesterday" in the frontend to match the actual data semantics. Quick fix, accurate UX.
  2. Fix the data — Implement a rolling 24h aggregation (either via a new upstream API endpoint, or a proxy endpoint in kleverscan-api that fetches recent blocks and aggregates client-side). Correct UX, requires backend work.
  3. Both — Fix labels now as a quick win, then implement true 24h data as a follow-up.

Affected files

  • src/pages/blocks/index.tsx — card labels and data binding
  • src/services/apiCalls.tsyesterdayStatisticsCall() function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions