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

refactor(dashboard): added unit tests for dashboard helpers #1309

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

sasha-bitfly
Copy link
Contributor

@sasha-bitfly sasha-bitfly commented Feb 5, 2025

Before we cover functions like GetValidatorDashboardSummary or GetValidatorDashboardGroupSummary with unit tests we need to cleanup and refactor a codebase.

Helper functions to be moved to vdb_helpers.go to avoid mess in vdb_dashboard.go

Every function is split into build query, execute query, process results

Generic executeQuery function is added

@sasha-bitfly sasha-bitfly changed the title refactor(dashboard): added unit tests for helper functions refactor(dashboard): added unit tests for dashboard helpers Feb 5, 2025
@sasha-bitfly sasha-bitfly force-pushed the BEDS-1006/unit-tests-for-dashboard-helpers branch from 59a3c87 to 3e13c77 Compare February 5, 2025 14:15
Copy link
Contributor

@LuccaBitfly LuccaBitfly left a comment

Choose a reason for hiding this comment

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

This is moving in a very nice direction, nice work! Still have a few comments, pls have a look.

@sasha-bitfly sasha-bitfly force-pushed the BEDS-1006/unit-tests-for-dashboard-helpers branch from cf5f0d8 to 3e13c77 Compare February 7, 2025 10:10
Copy link

cloudflare-workers-and-pages bot commented Feb 7, 2025

Deploying beaconchain with  Cloudflare Pages  Cloudflare Pages

Latest commit: a3d29e2
Status: ✅  Deploy successful!
Preview URL: https://23a89c26.beaconchain.pages.dev
Branch Preview URL: https://beds-1006-unit-tests-for-das.beaconchain.pages.dev

View logs

@sasha-bitfly sasha-bitfly removed the request for review from remoterami February 14, 2025 09:22
Copy link
Contributor

@LuccaBitfly LuccaBitfly left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

@mccreedy-bitfly mccreedy-bitfly left a comment

Choose a reason for hiding this comment

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

Generally think we need to add a lot more comments, but think that this is moving things in the right direction!

Comment on lines 505 to 492
func (d *DataAccessService) getEpochStart(ctx context.Context, period enums.TimePeriod) (uint64, error) {
clickhouseTable, _, err := d.getTablesForPeriod(period)
if err != nil {
return 0, err
}

ds := buildEpochStartQuery(clickhouseTable)
epochStart, err := getContext[uint64](ctx, d.clickhouseReader, ds)
if err != nil {
return 0, err
}

return epochStart, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we have this defined somewhere already as a general purpose query?

Copy link
Contributor Author

@sasha-bitfly sasha-bitfly Feb 19, 2025

Choose a reason for hiding this comment

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

We don't have general function for getting epoch start.
We need to make one during refactoring and include more fields: e.g. epoch_start, epoch_end, etc

@sasha-bitfly sasha-bitfly force-pushed the BEDS-1006/unit-tests-for-dashboard-helpers branch 2 times, most recently from a3d29e2 to 628371b Compare February 19, 2025 21:46
@sasha-bitfly sasha-bitfly force-pushed the BEDS-1006/unit-tests-for-dashboard-helpers branch from 628371b to 9558234 Compare February 19, 2025 22:11
@sasha-bitfly sasha-bitfly merged commit f636ec0 into staging Feb 19, 2025
3 checks passed
@sasha-bitfly sasha-bitfly deleted the BEDS-1006/unit-tests-for-dashboard-helpers branch February 19, 2025 22:15
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