Skip to content

Commit

Permalink
fix(users): fix count calculation when FK is null. ref #419
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Oct 2, 2024
1 parent a075918 commit f2f6d9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions open_prices/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def update_location_count(self):
from open_prices.prices.models import Price

self.location_count = (
Price.objects.filter(owner=self.user_id)
Price.objects.filter(owner=self.user_id, location_id__isnull=False)
.values_list("location_id", flat=True)
.distinct()
.count()
Expand All @@ -57,7 +57,7 @@ def update_product_count(self):
from open_prices.prices.models import Price

self.product_count = (
Price.objects.filter(owner=self.user_id)
Price.objects.filter(owner=self.user_id, product_id__isnull=False)
.values_list("product_id", flat=True)
.distinct()
.count()
Expand All @@ -68,7 +68,7 @@ def update_proof_count(self):
from open_prices.prices.models import Price

self.proof_count = (
Price.objects.filter(owner=self.user_id)
Price.objects.filter(owner=self.user_id, proof_id__isnull=False)
.values_list("proof_id", flat=True)
.distinct()
.count()
Expand Down
1 change: 0 additions & 1 deletion open_prices/users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def setUpTestData(cls):
product_code="0123456789101",
location_osm_id=cls.location.osm_id,
location_osm_type=cls.location.osm_type,
proof_id=cls.proof.id,
price=2.0,
owner=cls.user.user_id,
)
Expand Down

0 comments on commit f2f6d9c

Please sign in to comment.