Add needs_price_update field to Purchase model #94

Merged
lukas merged 3 commits from purchase-needs-price-update into main 2026-05-12 13:03:34 +00:00
5 changed files with 209 additions and 66 deletions
Showing only changes of commit e3b53cd4a9 - Show all commits
@@ -0,0 +1,22 @@
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
# Generated by Django 6.0.1 on 2026-05-12 11:57
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
from django.db import migrations, models
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
class Migration(migrations.Migration):
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
dependencies = [
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
('games', '0015_alter_purchase_date_purchased_and_more'),
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
]
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
operations = [
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
migrations.AddField(
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
model_name='purchase',
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
name='needs_price_update',
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
field=models.BooleanField(db_index=True, default=True),
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
),
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
migrations.RunSQL(
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
"UPDATE games_purchase SET needs_price_update = FALSE WHERE converted_price IS NOT NULL AND converted_currency != ''",
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
reverse_sql="UPDATE games_purchase SET needs_price_update = TRUE WHERE converted_price IS NOT NULL AND converted_currency != ''",
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
),
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
]
lukas marked this conversation as resolved
Review

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.

The raw SQL UPDATE in this migration could lock the table on large datasets. Consider chunked updates if the table grows significantly.
+1 -19
View File
@@ -179,6 +179,7 @@ class Purchase(models.Model):
price_currency = models.CharField(max_length=3, default="USD")
converted_price = models.FloatField(null=True)
converted_currency = models.CharField(max_length=3, blank=True, default="")
needs_price_update = models.BooleanField(default=True, db_index=True)
price_per_game = GeneratedField(
expression=Coalesce(F("converted_price"), F("price"), 0) / F("num_purchases"),
output_field=models.FloatField(),
@@ -240,12 +241,6 @@ class Purchase(models.Model):
def is_game(self):
return self.type == self.GAME
def price_or_currency_differ_from(self, purchase_to_compare):
return (
self.price != purchase_to_compare.price
or self.price_currency != purchase_to_compare.price_currency
)
def refund(self):
self.date_refunded = timezone.now()
self.save()
@@ -255,19 +250,6 @@ class Purchase(models.Model):
raise ValidationError(
f"{self.get_type_display()} must have a related purchase."
)
if self.pk is not None:
# Retrieve the existing instance from the database
existing_purchase = Purchase.objects.get(pk=self.pk)
# If price has changed, reset converted fields
if existing_purchase.price_or_currency_differ_from(self):
from games.tasks import currency_to
exchange_rate = get_or_create_rate(
self.price_currency, currency_to, self.date_purchased.year
)
if exchange_rate:
self.converted_price = floatformat(self.price * exchange_rate, 0)
self.converted_currency = currency_to
super().save(*args, **kwargs)
+23
View File
@@ -17,6 +17,29 @@ from games.models import Game, GameStatusChange, Purchase, Session
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
logger = logging.getLogger("games")
@receiver(pre_save, sender=Purchase)
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
def store_purchase_price_snapshot(sender, instance, **kwargs):
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
"""Store old price values before save so we can detect changes."""
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
if instance.pk is not None:
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
try:
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
old_instance = sender.objects.get(pk=instance.pk)
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
instance._old_price = old_instance.price
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
instance._old_currency = old_instance.price_currency
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
except sender.DoesNotExist:
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
pass
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
@receiver(post_save, sender=Purchase)
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
def mark_needs_price_update(sender, instance, created, **kwargs):
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
"""Mark purchase for price update if price or currency changed."""
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
if not created and hasattr(instance, "_old_price"):
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
if (
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
instance.price != instance._old_price
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
or instance.price_currency != instance._old_currency
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
):
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
sender.objects.filter(pk=instance.pk).update(needs_price_update=True)
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
@receiver(m2m_changed, sender=Purchase.games.through)
def update_num_purchases(sender, instance, action, reverse, **kwargs):
if not reverse and action.startswith("post_"):
lukas marked this conversation as resolved
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
Review

This signal handler fetches the old instance from the DB on every update. The old code in save() also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.

This signal handler fetches the old instance from the DB on every update. The old code in `save()` also fetched from DB, so it's a wash query-wise — not strictly fewer queries. Just worth noting the trade-off.
+41 -31
View File
@@ -1,6 +1,7 @@
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
import logging
import requests
from django.db import models
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
from django.template.defaultfilters import floatformat
logger = logging.getLogger("games")
@@ -12,41 +13,18 @@ currency_to = "CZK"
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
currency_to = currency_to.upper()
def save_converted_info(purchase, converted_price, converted_currency):
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
logger.info(
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
f"Setting converted price of {purchase} to {converted_price} {converted_currency} (originally {purchase.price} {purchase.price_currency})"
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
)
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
purchase.converted_price = converted_price
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
purchase.converted_currency = converted_currency
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
purchase.save()
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
def convert_prices():
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
purchases = Purchase.objects.filter(
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
converted_price__isnull=True, converted_currency=""
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
)
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
if purchases.count() == 0:
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
logger.info("[convert_prices]: No prices to convert.")
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
for purchase in purchases:
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
if purchase.price_currency.upper() == currency_to or purchase.price == 0:
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
save_converted_info(purchase, purchase.price, currency_to)
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
continue
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
year = purchase.date_purchased.year
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
currency_from = purchase.price_currency.upper()
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
exchange_rate = ExchangeRate.objects.filter(
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
currency_from=currency_from, currency_to=currency_to, year=year
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
).first()
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
def _get_exchange_rate(currency_from, currency_to, year):
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
logger.info(
f"[convert_prices]: Looking for exchange rate in database: {currency_from}->{currency_to}"
)
exchange_rate = ExchangeRate.objects.filter(
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
currency_from=currency_from, currency_to=currency_to, year=year
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
).first()
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
if not exchange_rate:
logger.info(
f"[convert_prices]: Getting exchange rate from {currency_from} to {currency_to} for {year}..."
)
try:
# this API endpoint only accepts lowercase currency string
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
response = requests.get(
f"https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@{year}-01-01/v1/currencies/{currency_from.lower()}.json"
)
@@ -54,7 +32,6 @@ def convert_prices():
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
data = response.json()
currency_from_data = data.get(currency_from.lower())
rate = currency_from_data.get(currency_to.lower())
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
if rate:
logger.info(f"[convert_prices]: Got {rate}, saving...")
exchange_rate = ExchangeRate.objects.create(
@@ -63,17 +40,50 @@ def convert_prices():
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
year=year,
rate=floatformat(rate, 2),
)
exchange_rate = exchange_rate.rate
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
else:
logger.info("[convert_prices]: Could not get an exchange rate.")
except requests.RequestException as e:
logger.info(
f"[convert_prices]: Failed to fetch exchange rate for {currency_from}->{currency_to} in {year}: {e}"
)
elif exchange_rate:
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
exchange_rate = exchange_rate.rate
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
return exchange_rate
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
def _save_converted_price(purchase, converted_price, needs_update):
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
logger.info(
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
f"Setting converted price of {purchase} to {converted_price} {currency_to} (originally {purchase.price} {purchase.price_currency})"
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
)
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
purchase.converted_price = converted_price
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
purchase.converted_currency = currency_to
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
if needs_update:
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
purchase.needs_price_update = False
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
purchase.save(update_fields=["converted_price", "converted_currency", "needs_price_update"])
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
def convert_prices():
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
purchases = Purchase.objects.filter(
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
models.Q(needs_price_update=True) | models.Q(converted_price__isnull=True)
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
).distinct()
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
if purchases.count() == 0:
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
logger.info("[convert_prices]: No prices to convert.")
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
return
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
for purchase in purchases:
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
needs_update = purchase.needs_price_update
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
if purchase.price_currency.upper() == currency_to or purchase.price == 0:
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
_save_converted_price(purchase, purchase.price, needs_update)
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
continue
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
year = purchase.date_purchased.year
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
currency_from = purchase.price_currency.upper()
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
exchange_rate = _get_exchange_rate(currency_from, currency_to, year)
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
if exchange_rate:
save_converted_info(
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
_save_converted_price(
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
purchase,
floatformat(purchase.price * exchange_rate.rate, 0),
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
currency_to,
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
floatformat(purchase.price * exchange_rate, 0),
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
needs_update,
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
)
lukas marked this conversation as resolved
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
Review

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to rate.

_get_exchange_rate() returns a bare float (not an ExchangeRate object), but the variable name is misleading. Consider renaming to `rate`.
Review

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.

Exchange rate lookups use logger.info() — consider logger.debug() for these routine operations.
+108 -2
View File
@@ -1,3 +1,109 @@
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
from django.test import TestCase
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
from datetime import date
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
# Create your tests here.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
from django.test import TestCase, override_settings
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
from games.models import Game, Platform, Purchase
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
from games.tasks import convert_prices
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
class PurchaseNeedsPriceUpdateTest(TestCase):
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
def setUp(self):
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
self.platform = Platform.objects.create(name="PC", icon="pc", group="PC")
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
self.game = Game.objects.create(name="Test Game", platform=self.platform)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
def test_new_purchase_has_needs_price_update_true(self):
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase = Purchase.objects.create(
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
price=50.0,
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
price_currency="USD",
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
date_purchased=date(2025, 1, 1),
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.games.add(self.game)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
self.assertTrue(purchase.needs_price_update)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
def test_convert_prices_sets_flag_to_false(self):
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase = Purchase.objects.create(
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
price=50.0,
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
price_currency="USD",
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
date_purchased=date(2025, 1, 1),
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.games.add(self.game)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
self.assertTrue(purchase.needs_price_update)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
with override_settings(
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
CACHES={
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
"default": {
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
"BACKEND": "django.core.cache.backends.locmem.LocMemCache"
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
}
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
}
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
):
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
convert_prices()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.refresh_from_db()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
self.assertFalse(purchase.needs_price_update)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
def test_price_change_sets_needs_price_update(self):
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase = Purchase.objects.create(
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
price=50.0,
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
price_currency="USD",
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
date_purchased=date(2025, 1, 1),
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.games.add(self.game)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.converted_price = 1000
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.converted_currency = "CZK"
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.needs_price_update = False
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.save()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.price = 60.0
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.save()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.refresh_from_db()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
self.assertTrue(purchase.needs_price_update)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
def test_currency_change_sets_needs_price_update(self):
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase = Purchase.objects.create(
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
price=50.0,
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
price_currency="USD",
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
date_purchased=date(2025, 1, 1),
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.games.add(self.game)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.converted_price = 1000
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.converted_currency = "CZK"
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.needs_price_update = False
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.save()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.price_currency = "EUR"
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.save()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.refresh_from_db()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
self.assertTrue(purchase.needs_price_update)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
def test_name_change_does_not_set_needs_price_update(self):
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase = Purchase.objects.create(
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
price=50.0,
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
price_currency="USD",
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
date_purchased=date(2025, 1, 1),
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.games.add(self.game)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.converted_price = 1000
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.converted_currency = "CZK"
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.needs_price_update = False
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.save()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.name = "New Name"
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.save()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.refresh_from_db()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
self.assertFalse(purchase.needs_price_update)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
def test_convert_prices_skips_already_converted(self):
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase = Purchase.objects.create(
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
price=50.0,
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
price_currency="USD",
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
date_purchased=date(2025, 1, 1),
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.games.add(self.game)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.converted_price = 1000
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.converted_currency = "CZK"
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.needs_price_update = False
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.save()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
convert_prices()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
purchase.refresh_from_db()
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
self.assertFalse(purchase.needs_price_update)
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
lukas marked this conversation as resolved
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.
Review

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.

override_settings(CACHES=...) seems unnecessary since convert_prices() doesn't use caching. Could be removed if left from an earlier version.