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

start_date and end_date filter on balance API doesn't work correctly if an exisiting balance snapshot is present #109

Open
amitex007 opened this issue Nov 15, 2023 · 1 comment

Comments

@amitex007
Copy link

amitex007 commented Nov 15, 2023

Hi Medici team,
It seems that the balance API doesn't return the correct values if there is a cached balance entry in balance_snapshots.
If the start_date and end_date are values before the last transaction Id in the snapshot, the balance API just returns the balance in the snapshot.
link

I suggest that we should also maintain a start_time and end_time in the balance snapshot and check if the range query can be satisfied by the snapshot. Else recalculate accordingly.
Happy to raise a PR for the same if we agree on a solution.
Or please suggest a work-around which doesn't turn the caching feature completely off.

Thanks

@koresar
Copy link
Collaborator

koresar commented Nov 16, 2023

Hello

Thanks for reporting! The idea behind caching the balances is that the key for the cache would be the mongodb query itself. However, looks like we have a bug. The getBestSnapshot() should take dates into account for sure.

The correct fix would be:

  • pass both dates to the getBestSnapshot
  • the getBestSnapshot should use them to calculate the cache key

We'd be happy with your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants