-
Notifications
You must be signed in to change notification settings - Fork 3
Feat/paginate payments endpoint #892
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
|
Tests failing. |
Klakurka
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.
734222c to
2d87333
Compare
Klakurka
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.
This is happening on master, I put #897 up to fix it |
|
Needs a rebase. |
2d87333 to
f32747f
Compare
chedieck
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.
One thing about this PR is that it breaks the sorting using other columns. E.g, if we want to order by amount, there is not really a way to do that without looking at all the payments and then sorting them by amount.
Sorting by network would still be possible in this way, since the network of the address is in the cache key name.
The idea of the issue was to avoid fetching all this data at once, which is possible when the user has it ordered by date or network, but not in the other cases (amount & buttons). I don't really see a way out of it, so maybe we can use pagination only in the case that the ordering is set to happen by date and fetch the whole lot of the data if the user wants it sorted in some other way.
redis/paymentCache.ts
Outdated
| return allPayments | ||
| } | ||
|
|
||
| function sortByDate (keys: string[], order: 'ascending' | 'descending'): string[] { |
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.
more clear name: sortWeekKeysByDate, since this function is specific for it.
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.
more clear name: sortWeekKeysByDate, since this function is specific for it.
No need to do that anymore, since this is obsolete, it can be deleted. However, if you think this could be useful for a future task, just put a comment indicating that and rename it for more clarity.
don’t you think having two types of pagination might end up looking a bit messy? Because for backend pagination, it’s one component, and for frontend, it’s another. I’d have to create something super complex. Is it really worth it? |
Yeah, would be messy indeed. The main reason for this issue is that with many payments we get messages like "API response shouldn't be > 4MB", but the overall behavior is better the way already is, I think. |
|
I have an idea: when e.g. requesting it sorted by amount, fetch the list of payments normally (from the DB, in the server), sort it, and then serving it to the client paginated. This fixes the issue of having large API responses and keeps the better answer time if sorted by date. If sorted by amount the answer time will be basically the same as it was already, but is not bad already for what I've tested, even for large addresses. |
|
I'll wait for Estevao's review. |
4a6a95b to
729de7d
Compare
chedieck
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.
Payments for a button with only ecash address are showing as being bitcoin cash payments
84f3d90 to
3dbf6cb
Compare
|
Bug I mentioned looks solved, but now tests are failing. |
3dbf6cb to
02c386c
Compare
chedieck
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.
045c4d5 to
74b82d9
Compare
74b82d9 to
2315345
Compare
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.
Looks good, but when ordering by button name, the network shows BCH icon where it should show the XEC icon.
chedieck
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.
Added requests for the code, many things reminiscent of earlier stages of this PR that need not be created anymore.
redis/paymentCache.ts
Outdated
| return allPayments | ||
| } | ||
|
|
||
| function sortByDate (keys: string[], order: 'ascending' | 'descending'): string[] { |
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.
more clear name: sortWeekKeysByDate, since this function is specific for it.
No need to do that anymore, since this is obsolete, it can be deleted. However, if you think this could be useful for a future task, just put a comment indicating that and rename it for more clarity.
there was a typo in the query, fixed |
chedieck
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.
Looks good!



Related to #741
Description
Added server side pagination to payments page, before the payments where fetched all at once in a single api call and the pagination was made in the client, now the client will fetch payments using page and pageSize parameters.
Changed Pagination to fetch tx data from database instead of cache, because it was too complex to paginate and order getting data from cache.
Test plan
Run server and check payments page pagination, try to change pageSize and pass between the pages