-
Notifications
You must be signed in to change notification settings - Fork 14
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: refactor consumer info metrics #66
Conversation
WalkthroughThe update primarily refactors how consumer information is managed and generated. The Changes
Sequence Diagram(s)sequenceDiagram
participant AppConfig
participant App
participant ConsumerInfoGenerator
participant ConsumerInfoFetcher
AppConfig->>App: Provide Chains
App->>ConsumerInfoGenerator: Initialize with Chains
ConsumerInfoGenerator->>ConsumerInfoFetcher: Fetch Consumer Data
ConsumerInfoFetcher->>ConsumerInfoGenerator: Return Nested Map Data
ConsumerInfoGenerator->>App: Return Generated Consumer Info
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- pkg/app.go (1 hunks)
- pkg/fetchers/consumer_info.go (3 hunks)
- pkg/fetchers/consumer_info_test.go (2 hunks)
- pkg/generators/consumer_info.go (4 hunks)
- pkg/generators/consumer_info_test.go (3 hunks)
Additional context used
Learnings (3)
pkg/generators/consumer_info_test.go (1)
User: freak12techno PR: QuokkaStake/cosmos-validators-exporter#64 File: pkg/config/consumer_chain_test.go:63-63 Timestamp: 2024-06-25T21:31:42.607Z Learning: In `pkg/config/consumer_chain_test.go`, incomplete `DenomInfos` fields are intentionally set to trigger validation failures as part of testing error handling.
pkg/fetchers/consumer_info.go (1)
User: freak12techno PR: QuokkaStake/cosmos-validators-exporter#63 File: pkg/fetchers/consumer_info.go:34-40 Timestamp: 2024-06-23T11:24:17.378Z Learning: User freak12techno plans to add unit tests for the `NewConsumerInfoFetcher` constructor later.
pkg/fetchers/consumer_info_test.go (2)
User: freak12techno PR: QuokkaStake/cosmos-validators-exporter#63 File: pkg/fetchers/consumer_validators.go:40-40 Timestamp: 2024-06-23T16:11:23.143Z Learning: The `TestConsumerValidatorsFetcherBase` method in `pkg/fetchers/consumer_validators_test.go` tests the initialization of `ConsumerValidatorsFetcher` with the `Chains` parameter.
User: freak12techno PR: QuokkaStake/cosmos-validators-exporter#63 File: pkg/fetchers/consumer_info.go:34-40 Timestamp: 2024-06-23T11:24:17.378Z Learning: User freak12techno plans to add unit tests for the `NewConsumerInfoFetcher` constructor later.
Additional comments not posted (12)
pkg/generators/consumer_info_test.go (3)
4-4
: Added import statement forconfig
.This import is necessary for the updated constructor of
ConsumerInfoGenerator
that now requires a slice ofconfig.Chain
.
23-23
: Updated constructor usage inTestConsumerInfoGeneratorNoState
.The test now correctly uses the new constructor signature by passing an empty slice of
config.Chain
.
33-51
: Updated test setup inTestConsumerInfoGeneratorNotEmptyState
.The test now uses a nested map structure for
ConsumerInfoData
. This aligns with the changes in the data structure ofConsumerInfoFetcher
. Also, the test correctly sets up a more complex state to reflect different scenarios.pkg/generators/consumer_info.go (4)
4-4
: Added import statement forconfig
.This import is necessary for the changes in the
ConsumerInfoGenerator
class to handle configurations.
13-13
: AddedChains
field toConsumerInfoGenerator
.This field is crucial for the generator to maintain a list of chains, which is used in the
Generate
method to process consumer information based on configurations.
16-17
: Updated constructor to initializeChains
field.The constructor now properly initializes the
Chains
field with the passed argument, aligning with the new requirement to handle multiple chains.
Line range hint
36-74
: UpdatedGenerate
method to use nested map structure and chain configurations.The method now iterates over chains and their consumer chains to generate metrics. This is a significant change that aligns with the new data structures and requirements. Ensure that the metrics generated are correctly labeled and calculated based on the new structure.
pkg/fetchers/consumer_info.go (2)
25-25
: Updated data structures to nested maps.The
allInfos
andInfo
fields have been updated to use nested map structures. This change is crucial for supporting more complex data relationships as required by the new features.Also applies to: 29-29
Line range hint
50-103
: RefactoredFetch
andprocessChain
methods to initialize and populate nested maps.These methods have been significantly updated to work with the new nested map structures. The
Fetch
method initializes the structure, andprocessChain
populates it based on fetched data. Ensure that error handling and logging are adequately addressed in these methods.pkg/fetchers/consumer_info_test.go (2)
114-114
: Updated assertion inTestConsumerInfoFetcherQueryDisabled
.The test now correctly asserts that the
Info
field is empty, which is expected behavior when the query is disabled. This change is necessary due to the updated data structure.
240-240
: Updated assertion inTestConsumerInfoFetcherQuerySuccess
.The test now checks the length of
chainData
to verify the correct handling of data in the new nested map structure. This is a crucial aspect to ensure the fetcher processes and stores data correctly.pkg/app.go (1)
119-119
: UpdatedNewConsumerInfoGenerator
usage inApp
constructor.The
App
constructor now correctly initializes theConsumerInfoGenerator
with theappConfig.Chains
, aligning with the updated constructor requirements. This ensures that the generator has the necessary configuration data to operate.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Tests