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

[MEX-527] Refactor pair filtering #1536

Open
wants to merge 2 commits into
base: MEX-527-bulk-getters
Choose a base branch
from

Conversation

mad2sm0key
Copy link
Contributor

@mad2sm0key mad2sm0key commented Dec 11, 2024

Reasoning

  • duplicate code for filtering pairs
  • the Pair memory store service (PR#1539) will also benefit from this refactoring

Proposed Changes

  • update PairFilteringService to work with pair models with the fields already populated (functional service)
  • update PairMetadataBuilder to use the functional filtering service
  • update pair methods (regular and filtered) in router service to use the builder
  • remove duplicate code in router service

How to test

  • N/A

- update PairFilteringService to work with pair models with the fields already populated (functional service)
- update PairMetadataBuilder to use the functional filtering service
- update pair methods (regular and filtered) in router service to use the builder
- remove duplicate code in router service
@mad2sm0key mad2sm0key marked this pull request as ready for review December 12, 2024 12:37
this.pairs.map((pair) => pair.address),
);

this.pairs.forEach(

Choose a reason for hiding this comment

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

it wouldn't make a much difference here, but for a high number of iterations, forEach is the least efficient way of ranging:

this.filters,
this.pairsMetadata,
this.pairs,
);
return this;
Copy link
Collaborator

Choose a reason for hiding this comment

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

All these filters from PairsMetadataBuilder should return the actual filtered pairs, not an instance of the class

this.pairsMetadata = pairsMetadata;
this.filters = filters;
this.filteringService = filteringService;
constructor(pairService: PairService, pairCompute: PairComputeService) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can inject all the services in the constructor and also inject the builder class where it is used


pairsMetadata = await builder.build();
let pairs = builder.build();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need it anymore after the changes on the filtering methods

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