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

fix(stats): improve stats app resiliency #385

Merged

Conversation

forbesus
Copy link
Contributor

ref #330

@forbesus
Copy link
Contributor Author

Hello @baktun14 would you check it?

apps/api/src/services/db/statsService.ts Outdated Show resolved Hide resolved
apps/api/src/services/external/apiNodeService.ts Outdated Show resolved Hide resolved
apps/api/src/routes/v1/dashboardData.ts Outdated Show resolved Hide resolved
apps/api/src/services/db/statsService.ts Outdated Show resolved Hide resolved
apps/api/src/routes/v1/dashboardData.ts Outdated Show resolved Hide resolved
apps/api/src/routes/v1/dashboardData.ts Outdated Show resolved Hide resolved
apps/api/src/services/external/apiNodeService.ts Outdated Show resolved Hide resolved
apps/api/src/services/external/apiNodeService.ts Outdated Show resolved Hide resolved
apps/stats-web/src/app/(home)/DashboardContainer.tsx Outdated Show resolved Hide resolved
@forbesus
Copy link
Contributor Author

forbesus commented Oct 1, 2024

Hello @Redm4x @ygrishajev
I finished to fix
Would you check again?

apps/api/src/routes/v1/dashboardData.ts Outdated Show resolved Hide resolved
apps/api/src/services/external/apiNodeService.ts Outdated Show resolved Hide resolved
apps/api/src/services/external/apiNodeService.ts Outdated Show resolved Hide resolved
@forbesus
Copy link
Contributor Author

forbesus commented Oct 2, 2024

Hello @ygrishajev I just fixed
Would you check again?

apps/api/src/services/external/apiNodeService.ts Outdated Show resolved Hide resolved
apps/api/src/services/external/apiNodeService.ts Outdated Show resolved Hide resolved
apps/api/src/services/external/apiNodeService.ts Outdated Show resolved Hide resolved
apps/api/src/services/external/apiNodeService.ts Outdated Show resolved Hide resolved
apps/api/src/services/external/apiNodeService.ts Outdated Show resolved Hide resolved
@forbesus
Copy link
Contributor Author

forbesus commented Oct 2, 2024

Hello @ygrishajev How about now?

Copy link
Contributor

@ygrishajev ygrishajev left a comment

Choose a reason for hiding this comment

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

Thanks for all your changes @forbesus! This looks so much better!

I'm adding a couple of comments, that you may improve further if you like. Anyways lgtm.
Let's please make sure it's also good with @Redm4x

height: latestBlocks && latestBlocks.length > 0 ? latestBlocks[0].height : undefined,
transactionCount: latestBlocks && latestBlocks.length > 0 ? latestBlocks[0].totalTransactionCount : undefined,
}
const latestTransactions = await runOrLog(() => getTransactions(5));
Copy link
Contributor

Choose a reason for hiding this comment

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

what do you think about one last improvement here? Promise.all should speed up this endpoint quite a bit

const [{ now, compare }, chainStatsQuery, networkCapacity, networkCapacityStats, latestBlocks, latestTransactions] = await Promise.all([
    runOrLog(getDashboardData),
    runOrLog(getChainStats, {
      bondedTokens: undefined,
      totalSupply: undefined,
      communityPool: undefined,
      inflation: undefined,
      stakingAPR: undefined
    }),
    runOrLog(getNetworkCapacity),
    runOrLog(() => getProviderGraphData("count")),
    runOrLog(() => getBlocks(5)),
    runOrLog(() => getTransactions(5))
  ]);

  const chainStats = {
    ...chainStatsQuery,
    height: latestBlocks && latestBlocks.length > 0 ? latestBlocks[0].height : undefined,
    transactionCount: latestBlocks && latestBlocks.length > 0 ? latestBlocks[0].totalTransactionCount : undefined
  };

apps/api/src/services/external/apiNodeService.ts Outdated Show resolved Hide resolved
@ygrishajev
Copy link
Contributor

oh, 1 thing before we can merge. Please squash the commits and use a scope for the resulting commits. e.g.

feat(stats): ...message

This should fail on pre-commit hook coz this scope is not added to our rules. Please feel free to add it.

@Redm4x does this scope make sense to you?

@forbesus forbesus force-pushed the feature/improve-stats-app-resiliency branch from ee40d6b to 3707f0a Compare October 2, 2024 20:09
@forbesus forbesus changed the title Improve stats app resiliency fix(stats): improve stats app resiliency Oct 2, 2024
@forbesus
Copy link
Contributor Author

forbesus commented Oct 2, 2024

All things are finished @Redm4x cc: @ygrishajev

@ygrishajev
Copy link
Contributor

We follow rebase strategy, can you squash the merge commit too pls?

feat: add try catch for stats

feat: improve stats app resiliency

fix: remove try catch from api

fix: avoid to confuse nodeService values

fix: add error handling by logging and sentry

fix: fix clean code

fix: add runOrLog function

fix: lint

fix: chagne logger name

fix: add error handling to node status

fix: add logging util

feat: improve speed to get stats

feat: add scope
@forbesus forbesus force-pushed the feature/improve-stats-app-resiliency branch from 5997f85 to 16e96ef Compare October 2, 2024 21:51
@forbesus
Copy link
Contributor Author

forbesus commented Oct 2, 2024

How about now? @ygrishajev cc: @Redm4x

Copy link
Contributor

@ygrishajev ygrishajev left a comment

Choose a reason for hiding this comment

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

Lgtm! Thanks for all your changes!

@Redm4x Redm4x merged commit 34dbbf1 into akash-network:main Oct 4, 2024
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