Skip to content

Commit

Permalink
New stats For Sale and Sold
Browse files Browse the repository at this point in the history
  • Loading branch information
JOJ0 committed Jan 17, 2025
1 parent 44d8851 commit 45db6b0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions discodos/ctrl/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,8 @@ def view_stats(self):
self.collection.stats_collection_items_discogs(),
self.collection.stats_sales_listings_discobase(),
self.collection.stats_sales_listings_discogs(),
self.collection.stats_sales_listings_forsale(),
self.collection.stats_sales_listings_sold(),
self.collection.stats_mixtracks_total(),
self.collection.stats_mixtracks_unique(),
self.collection.stats_tracks_key_brainz(),
Expand Down
14 changes: 14 additions & 0 deletions discodos/model/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,20 @@ def stats_sales_listings_discobase(self):
stats = self._select(sql_stats, fetchone=True)
return stats[0] if stats else 0

def stats_sales_listings_forsale(self):
sql_stats = """ SELECT COUNT(*) FROM sales
WHERE d_sales_status = "forsale" OR d_sales_status = "expired";
"""
stats = self._select(sql_stats, fetchone=True)
return stats[0] if stats else 0

def stats_sales_listings_sold(self):
sql_stats = '''
SELECT COUNT(*) FROM sales WHERE d_sales_status = "sold";
'''
stats = self._select(sql_stats, fetchone=True)
return stats[0] if stats else 0

def stats_mixtracks_total(self):
sql_stats = '''
SELECT COUNT(*) FROM mix_track;
Expand Down
4 changes: 4 additions & 0 deletions discodos/view/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def tab_stats(
tracks_total, tracks_matched,
collection_items_discobase, collection_items_discogs,
sales_listings_discobase, sales_listings_discogs,
sales_listings_forsale,
sales_listings_sold,
mixtracks_total, mixtracks_unique,
tracks_key_brainz, tracks_key_manual,
tracks_bpm_brainz, tracks_bpm_manual
Expand All @@ -141,6 +143,8 @@ def tab_stats(
['Collection items (Discogs)', collection_items_discogs],
['Sales listings (DiscoBASE)', sales_listings_discobase],
['Sales listings (Discogs)', sales_listings_discogs],
['Sales listings (For Sale/Expired)', sales_listings_forsale],
['Sales listings (Sold)', sales_listings_sold],
['Releases matched with *Brainz', releases_matched],
['Tracks in DiscoBASE', tracks_total],
['Tracks matched with *Brainz', tracks_matched],
Expand Down

0 comments on commit 45db6b0

Please sign in to comment.