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

How should Numbat handle exchange currency fetching over long-lived sessions? #315

Open
triallax opened this issue Feb 5, 2024 · 4 comments
Labels

Comments

@triallax
Copy link
Collaborator

triallax commented Feb 5, 2024

Relevant IRC discussion: #139 (comment)

After Numbat fetches currency exchange rates, they are stored for the duration of the session without ever being refreshed. This is problematic for long-running sessions because exchange rates fluctuate over time, and so in a Numbat session running over e.g. a week, the rates will become outdated.

One solution is to fetch them regularly, say once a day (maybe make the frequency configurable?). We could also make it configurable whether to prefetch them at that frequency or to only fetch them after they're outdated and a currency unit was used. This solution raises the question of how to handle network errors when refetching the exchange rates; we should probably let the user know about the failure lest they use outdated exchange rate information.

Thoughts?

@sharkdp
Copy link
Owner

sharkdp commented Feb 5, 2024

I don't think we need an additional config option for this (in the beginning). The update rate should probably be equal to the update rate of the source (ECB exchange rates), which is once per day, IIRC.

@bsidhom
Copy link

bsidhom commented Feb 21, 2024

On the note of ECB data: is there a reason this request is proxied through a PHP server rather than queried directly? I came across this while looking into what it would take to make Numbat into a PWA with full offline support. The proxying doesn’t really change that at all, but it does make the deployment of Numbat less self-contained. Is this just for caching purposes in order to be nicer to the ECB service?

@sharkdp
Copy link
Owner

sharkdp commented Feb 21, 2024

On the note of ECB data: is there a reason this request is proxied through a PHP server rather than queried directly?

Yes. I was running into CORS issues when attempting to let the client access the ECB server directly. I'm not an expert on this topic, so please let me know if you think there is a better solution. I'd love to get rid of the proxy step.

caching purposes in order to be nicer to the ECB service?

That's another potential reason, but not the main one. And with the current number of Numbat users, I think we're good :-)

@bsidhom
Copy link

bsidhom commented Feb 21, 2024

Ah, unfortunately I’m not sure of any ways around that. I thought maybe service workers could offer an escape hatch (since they proxy all requests under the page scope), but they’re bound by the same cross-origin rules and only get access to opaque responses.

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

No branches or pull requests

3 participants