tiffany352 / rink-rs

Unit conversion tool and library written in rust
https://rinkcalc.app/about
GNU General Public License v3.0
442 stars 28 forks source link

Unit is malformed: no such unit #115

Closed coder543 closed 2 years ago

coder543 commented 2 years ago

Within the last several days, n several of my machines (all that I've tested), rink has started outputting this every time I start it:

$ rink
Unit копеика is malformed: No such unit RUB, did you mean ruby?
Unit kopek is malformed: No such unit копеика
Unit rouble is malformed: No such unit RUB, did you mean ruby?
Unit ruble is malformed: No such unit RUB, did you mean ruby?
Unit копеики is malformed: No such unit копеика
Unit рубль is malformed: No such unit RUB, did you mean ruby?
Unit ₽ is malformed: No such unit RUB, did you mean ruby?
> 

I haven't had time to dig in and understand what's happening, but I'm assuming some upstream currency format changed in an incompatible way.

tiffany352 commented 2 years ago

It looks like the European Central Bank deleted the Ruble from their currency data. I can probably fix this on the backend side by including a hardcoded value for Ruble <-> Euro.

According to the ECB:

Owing to current trading activity in the EUR/RUB market, the European Central Bank (ECB) is not in a position to set a reference rate that is representative of prevailing market conditions. The ECB has therefore decided to suspend its publication of a euro reference rate for the Russian rouble until further notice. The ECB last published a EUR/RUB reference rate on 1 March 2022.

tiffany352 commented 2 years ago

Fixed in f10a39c01e8332948f1be367c559904f4ffb70f3 which should automatically roll out to everyone using 0.6+ (since it fetches the data from https://rinkcalc.app/data/currency.json by default). I actually added default values for all ECB currencies so this exact failure shouldn't happen again.

Data for the Ruble won't live update until I can find an API for it. A lot of the ones I've seen are paid access only.

❯ ruble
Definition: RUB = (1 / 141.951) EUR = approx. 7.044684 millieuro (money; EUR). Fetching live data failed. Fallback value provided from xe.com on 2022-03-09.