From f6128ecc4a9d2f487843cbc70e074188b981b380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Thu, 28 Aug 2025 16:58:33 +0200 Subject: [PATCH] Currency.py: remove unused methods - rates2, convert --- brmbar3/brmbar/Currency.py | 51 -------------------------------------- 1 file changed, 51 deletions(-) diff --git a/brmbar3/brmbar/Currency.py b/brmbar3/brmbar/Currency.py index 61d6a75..fba3059 100644 --- a/brmbar3/brmbar/Currency.py +++ b/brmbar3/brmbar/Currency.py @@ -67,57 +67,6 @@ class Currency: return (buy, sell) - def rates2(self, other): - # the original code for compare testing - res = self.db.execute_and_fetch( - "SELECT rate, rate_dir FROM exchange_rates WHERE target = %s AND source = %s AND valid_since <= NOW() ORDER BY valid_since DESC LIMIT 1", - [self.id, other.id], - ) - if res is None: - raise NameError( - "Currency.rate(): Unknown conversion " - + other.name() - + " to " - + self.name() - ) - buy_rate, buy_rate_dir = res - buy = buy_rate if buy_rate_dir == "target_to_source" else 1 / buy_rate - - res = self.db.execute_and_fetch( - "SELECT rate, rate_dir FROM exchange_rates WHERE target = %s AND source = %s AND valid_since <= NOW() ORDER BY valid_since DESC LIMIT 1", - [other.id, self.id], - ) - if res is None: - raise NameError( - "Currency.rate(): Unknown conversion " - + self.name() - + " to " - + other.name() - ) - sell_rate, sell_rate_dir = res - sell = sell_rate if sell_rate_dir == "source_to_target" else 1 / sell_rate - - return (buy, sell) - - def convert(self, amount, target): - res = self.db.execute_and_fetch( - "SELECT rate, rate_dir FROM exchange_rates WHERE target = %s AND source = %s AND valid_since <= NOW() ORDER BY valid_since DESC LIMIT 1", - [target.id, self.id], - ) - if res is None: - raise NameError( - "Currency.convert(): Unknown conversion " - + self.name() - + " to " - + target.name() - ) - rate, rate_dir = res - if rate_dir == "source_to_target": - resamount = amount * rate - else: - resamount = amount / rate - return resamount - def str(self, amount): return "{:.2f} {}".format(amount, self.name)