Skip to content
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

feat: add category and rollup stats #576

Merged
merged 22 commits into from
Oct 4, 2024
Merged

feat: add category and rollup stats #576

merged 22 commits into from
Oct 4, 2024

Conversation

PJColombo
Copy link
Member

@PJColombo PJColombo commented Sep 19, 2024

Checklist

  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Resolves #518

This PR introduces changes to aggregate statistics by category and rollups, and stores them in the daily and overall stats tables. To achieve this, it adds optional category and rollup columns to these tables, allowing for grouped statistics.

If either of these columns is null, it indicates that the row reflects total stats for that grouping. Specifically, when rollup is null, the row holds the stats for all rollups. When both category and rollup are null, the row represents the overall total stats.

The PR also leverages Prisma’s new TypedSQL feature to implement type-safe raw SQL queries.

Additionally, it updates the unit tests to verify the validity and correctness of each aggregated value by comparing them against the aggregation of the fixture data, rather than checking against a snapshot, as we were doing so far.

Motivation and Context (Optional)

Related Issue (Optional)

Screenshots (if appropriate):

Copy link

changeset-bot bot commented Sep 19, 2024

🦋 Changeset detected

Latest commit: 6955439

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@blobscan/db Minor
@blobscan/dayjs Minor
@blobscan/stats-aggregation-cli Minor
@blobscan/syncers Minor
@blobscan/api Minor
@blobscan/web Patch
@blobscan/blob-propagation-jobs-cli Patch
@blobscan/auth Patch
@blobscan/blob-propagator Patch
@blobscan/blob-storage-manager Patch
@blobscan/rollups Patch
@blobscan/rest-api-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Sep 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
blobscan-docs ⬜️ Ignored (Inspect) Visit Preview Oct 4, 2024 3:43pm
blobscan-gnosis ⬜️ Ignored (Inspect) Visit Preview Oct 4, 2024 3:43pm
blobscan-holesky ⬜️ Ignored (Inspect) Visit Preview Oct 4, 2024 3:43pm
blobscan-mainnet ⬜️ Ignored (Inspect) Visit Preview Oct 4, 2024 3:43pm
blobscan-sepolia ⬜️ Ignored (Inspect) Visit Preview Oct 4, 2024 3:43pm
blobscan-staging ⬜️ Ignored (Inspect) Visit Preview Oct 4, 2024 3:43pm

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 91.22807% with 30 lines in your changes missing coverage. Please review.

Project coverage is 89.58%. Comparing base (8fbd67e) to head (6955439).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...kages/api/src/routers/stats/getBlobOverallStats.ts 76.00% 6 Missing ⚠️
...pi/src/routers/stats/getTransactionOverallStats.ts 79.31% 6 Missing ⚠️
packages/db/prisma/extensions/stats.ts 85.71% 6 Missing ⚠️
clis/stats-aggregation-cli/src/commands/daily.ts 72.22% 5 Missing ⚠️
packages/db/prisma/extensions/base.ts 94.59% 2 Missing ⚠️
packages/syncers/src/syncers/DailyStatsSyncer.ts 95.23% 2 Missing ⚠️
packages/test/src/fixtures/index.ts 97.91% 2 Missing ⚠️
...ages/api/src/routers/stats/getBlockOverallStats.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #576   +/-   ##
=======================================
  Coverage   89.58%   89.58%           
=======================================
  Files         153      153           
  Lines       10180    10180           
  Branches     1070     1070           
=======================================
  Hits         9120     9120           
  Misses       1060     1060           

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

Copy link
Member

@PabloCastellano PabloCastellano left a comment

Choose a reason for hiding this comment

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

Good job 💪 . I've left some comments

@PJColombo PJColombo merged commit 04565b2 into main Oct 4, 2024
13 of 14 checks passed
@PJColombo PJColombo deleted the feat/add-rollup-stats branch October 4, 2024 15:55
@github-actions github-actions bot mentioned this pull request Oct 6, 2024
luis-herasme pushed a commit that referenced this pull request Oct 13, 2024
* feat(db): add `category` and `rollup` to stats models

* fix(db): add missing `id` field to blob daily stats model

* chore: bump prisma deps to latest version

* chore(db): enable `typedSql` on prisma

* feat(db): add blob max fee columns to transaction stats models

* chore: add changeset

* feat(db): treat category and rollup null values as distinct

* feat(db): add total blob gas price columns

* feat(db): add address history model

* feat(dayjs): add date utily functions

* chore: add changeset

* feat: add support for category and rollup aggregations

* chore: add changeset

* test(stats-aggregation-cli): update snapshots

* fix(api): fix import issue

* style: apply suggestions from code review

Co-authored-by: Pablo Castellano <[email protected]>

* test(api): unskip tests

* refactor: rename `AddressHistory` model to `AddressCategoryInfo`

* feat: make `category` column optional on `AddressCategoryInfo` model

* feat(api): upsert lowest overall address category info

* style(stats-aggregation-cli): add comment

---------

Co-authored-by: Pablo Castellano <[email protected]>
@PJColombo PJColombo restored the feat/add-rollup-stats branch October 29, 2024 11:30
@PJColombo PJColombo deleted the feat/add-rollup-stats branch October 29, 2024 11:33
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.

Calculate stats by category and rollup
2 participants