stats4sd / aec_portfolio

A proof of concept for the AEC Consortium Project Management / Assessment System
GNU General Public License v3.0
0 stars 0 forks source link

Fix Historic Exchange Rate Command #263

Closed dan-tang-ssd closed 7 months ago

dan-tang-ssd commented 7 months ago

This PR is submitted to fix the historic exchange rate retrieval command.

This PR is not completed yet. I fixed issue 1 and I would like to update status first.


Issues found:

  1. In AppServiceProvider, we need to use different attribute according to different job. (FIXED)
    • use $date for GetOneDayExchangeRates
    • use $year for GetHistoricExchangeRates
  2. Free currency API does not support to retrieve exchange rate for a date range anymore... (TO BE FIXED)

Error message returned from Free currency APi:

[2024-03-20 14:48:54] local.ERROR: HTTP request returned status code 403:
{"message":"To get a range of historical data, please upgrade to currencyapi.com in your dashboard and use the \/range e (truncated...)

[2024-03-20 14:48:54] local.ERROR: HTTP request returned status code 403:
{"message":"To get a range of historical data, please upgrade to currencyapi.com in your dashboard and use the \/range e (truncated...)
 {"exception":"[object] (Illuminate\\Http\\Client\\RequestException(code: 403): HTTP request returned status code 403:
{\"message\":\"To get a range of historical data, please upgrade to currencyapi.com in your dashboard and use the \\/range e (truncated...)
 at C:\\public\\aec\\vendor\\laravel\\framework\\src\\Illuminate\\Http\\Client\\Response.php:272)
[stacktrace]
#0 C:\\public\\aec\\vendor\\laravel\\framework\\src\\Illuminate\\Http\\Client\\Response.php(289): Illuminate\\Http\\Client\\Response->toException()
#1 C:\\public\\aec\\app\\Jobs\\GetHistoricExchangeRates.php(67): Illuminate\\Http\\Client\\Response->throw(Object(Closure))
#2 C:\\public\\aec\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(36): App\\Jobs\\GetHistoricExchangeRates->handle()
what-the-diff[bot] commented 7 months ago

PR Summary

dave-mills commented 7 months ago

Question - if the GetHistoricExchangeRates no longer works because we cannot retrieve exchanges rates for more than 1 day at a time, why not remove that command and related job, and instead setup a command to push jobs for all days within a given time span?

dan-tang-ssd commented 7 months ago

Question - if the GetHistoricExchangeRates no longer works because we cannot retrieve exchanges rates for more than 1 day at a time, why not remove that command and related job, and instead setup a command to push jobs for all days within a given time span?

Yes. It is probably the simplest way. This is not quite worthy to revise program that will be used only once to get historic exchange rates data. Because we will get daily data everyday afterwards.

I recall that free currency has a monthly limit quota per month.

I sent a request and show headers of HTTP response. Checked that our monthly quota is 5000.

< x-ratelimit-limit-quota-month: 5000
< x-ratelimit-remaining-quota-month: 4298

We need to send 33 requests for 1 day. For 1 year we need to send 12,045 requests (33 * 365). Our monthly quota seems not enough for this approach...


URL: https://freecurrencyapi.com/docs/#authentication-methods

Screen shot:

image

dan-tang-ssd commented 7 months ago

As per our discussion, we will get historic exchange rate data via Google Finance + Google Sheets.

There is no need to change anything for the existing programs for retrieving exchange rate data in daily basis.

I will close this PR.