-
Notifications
You must be signed in to change notification settings - Fork 24
Adding pagination support for NftRepository #27
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
Conversation
hendrikebbers
left a comment
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.
Hey, thank you very much for this great contribution. I worked yesterday on the implementation of the MirrorNodeClient and did some simpolification for the uri handling. It would be good if you can update your branch and do the fix as described in the comments.
if you have any questions or need help please ping me.
| Objects.requireNonNull(accountId, "newAccountId must not be null"); | ||
| final JsonNode jsonNode = doGetCall("/api/v1/accounts/" + accountId + "/nfts"); | ||
| return jsonNodeToNftList(jsonNode); | ||
| final URI uri = URI.create( |
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.
Can you please update your branch with current main branch. I did some updates on the implementation that makes uri handling way more easy.
With that update I assume this method looks like this:
final String path = /api/v1/accounts/" + accountId + "/nfts";
final Function<JsonNode, List<Nft>> dataExtractionFunction = node -> getNfts(node);
return new RestBasedPage<>(objectMapper, restClient.mutate().clone(), path, dataExtractionFunction);
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.
i refactored the methods, please let me know if i did something wrong.
|
|
||
| //when | ||
| final List<Nft> result = nftRepository.findByOwner(newOwner); | ||
| final Page<Nft> slice = nftRepository.findByOwner(newOwner); |
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.
I updated the tests for the current methods that support pagination and added some tests that checks a return count that is bigger than the size of 1 page. By doing so we can directly check if the pagination works. Can you please add such tests, too.
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.
Tests added. Took me while to figure it out.
hendrikebbers
left a comment
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.
That looks great. I will run the tests and merge if all fits.
...spring/src/main/java/com/openelements/hedera/spring/implementation/MirrorNodeClientImpl.java
Outdated
Show resolved
Hide resolved
…lementation/MirrorNodeClientImpl.java
|
@henrique021 sorry for the delay. The contribution is great and I'm really happy for that. |
Pagination support added for the two following methods:
List findByOwner(@nonnull AccountId ownerId)
List findByOwnerAndType(@nonnull AccountId ownerId, @nonnull TokenId tokenId)