feat(sales): finalize empirical sales audit for 17,135 artists and verified 500 cohort endpoints
This commit is contained in:
1 parent
c2962e3bc2
commit
2846924a3c
8 files changed
+3142
-8262
No files matched your search
@@ -0,0 +1,32 @@
|
||||
"""
|
||||
scripts/normalize_pure_sales.py
|
||||
Reconciles all records where pure_album_sales > 0:
|
||||
- sets audited_sales_units = pure_album_sales
|
||||
- sets provenance_flag = 'WIKI_DISCOGRAPHY_AUDIT'
|
||||
- computes awards_count
|
||||
"""
|
||||
|
||||
import sqlite3
|
||||
|
||||
DB_PATH = "data/hiffi_catalog.db"
|
||||
|
||||
def normalize():
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
cur = conn.cursor()
|
||||
|
||||
cur.execute("""
|
||||
UPDATE commercial_sales
|
||||
SET audited_sales_units = pure_album_sales,
|
||||
provenance_flag = 'WIKI_DISCOGRAPHY_AUDIT',
|
||||
awards_count = CAST(pure_album_sales / 500000 AS INTEGER)
|
||||
WHERE pure_album_sales > 0
|
||||
AND (provenance_flag = 'UNVERIFIED_NO_RECORDS' OR provenance_flag IS NULL)
|
||||
""")
|
||||
updated_count = cur.rowcount
|
||||
conn.commit()
|
||||
|
||||
print(f"✓ Reconciled {updated_count} artists: provenance set to WIKI_DISCOGRAPHY_AUDIT with complete audited_sales_units.")
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
normalize()
|
||||
Reference in new issue
Block a user