You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: backend/app.py
+49Lines changed: 49 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -310,6 +310,55 @@ def settings(f):
310
310
returncollection_settings
311
311
312
312
313
+
@app.get("/api/summary")
314
+
defsummary(f):
315
+
collection_summary= {}
316
+
317
+
file=f
318
+
con=sqlite_connect(file)
319
+
cur=con.cursor()
320
+
321
+
res=cur.execute("SELECT count(*) FROM coins")
322
+
data=res.fetchall()
323
+
collection_summary['total_count'] =data[0][0]
324
+
325
+
res=cur.execute("SELECT count(*) FROM coins WHERE status IN ('owned', 'ordered', 'sale', 'duplicate', 'replacement')")
326
+
data=res.fetchall()
327
+
collection_summary['count_owned'] =data[0][0]
328
+
329
+
res=cur.execute("SELECT count(*) FROM coins WHERE status='wish'")
330
+
data=res.fetchall()
331
+
collection_summary['count_wish'] =data[0][0]
332
+
333
+
res=cur.execute("SELECT count(*) FROM coins WHERE status='sold'")
334
+
data=res.fetchall()
335
+
collection_summary['count_sold'] =data[0][0]
336
+
337
+
res=cur.execute("SELECT count(*) FROM coins WHERE status='bidding'")
338
+
data=res.fetchall()
339
+
collection_summary['count_bidding'] =data[0][0]
340
+
341
+
res=cur.execute("SELECT count(*) FROM coins WHERE status='missing'")
342
+
data=res.fetchall()
343
+
collection_summary['count_missing'] =data[0][0]
344
+
345
+
res=cur.execute("SELECT SUM(totalpayprice) FROM coins WHERE status IN ('owned', 'ordered', 'sale', 'sold', 'missing', 'duplicate', 'replacement') AND totalpayprice<>'' AND totalpayprice IS NOT NULL")
346
+
data=res.fetchall()
347
+
collection_summary['paid'] =data[0][0]
348
+
349
+
res=cur.execute("SELECT SUM(payprice) FROM coins WHERE status IN ('owned', 'ordered', 'sale', 'sold', 'missing', 'duplicate', 'replacement') AND payprice<>'' AND payprice IS NOT NULL")
res=cur.execute("SELECT paydate FROM coins WHERE status IN ('owned', 'ordered', 'sale', 'sold', 'missing', 'duplicate', 'replacement') AND paydate<>'' AND paydate IS NOT NULL ORDER BY paydate LIMIT 1")
sql="SELECT count(*) FROM coins WHERE status IN ('owned', 'ordered', 'sale', 'duplicate', 'replacement')"
548
+
results=awaitexecuteQuery(sql)
549
+
collection_summary['count_owned']=results[0][0]
550
+
551
+
sql="SELECT count(*) FROM coins WHERE status='wish'"
552
+
results=awaitexecuteQuery(sql)
553
+
collection_summary['count_wish']=results[0][0]
554
+
555
+
sql="SELECT count(*) FROM coins WHERE status='sold'"
556
+
results=awaitexecuteQuery(sql)
557
+
collection_summary['count_sold']=results[0][0]
558
+
559
+
sql="SELECT count(*) FROM coins WHERE status='bidding'"
560
+
results=awaitexecuteQuery(sql)
561
+
collection_summary['count_bidding']=results[0][0]
562
+
563
+
sql="SELECT count(*) FROM coins WHERE status='missing'"
564
+
results=awaitexecuteQuery(sql)
565
+
collection_summary['count_missing']=results[0][0]
566
+
567
+
sql="SELECT SUM(totalpayprice) FROM coins WHERE status IN ('owned', 'ordered', 'sale', 'sold', 'missing', 'duplicate', 'replacement') AND totalpayprice<>'' AND totalpayprice IS NOT NULL"
568
+
results=awaitexecuteQuery(sql)
569
+
collection_summary['paid']=results[0][0]
570
+
571
+
sql="SELECT SUM(payprice) FROM coins WHERE status IN ('owned', 'ordered', 'sale', 'sold', 'missing', 'duplicate', 'replacement') AND payprice<>'' AND payprice IS NOT NULL"
sql="SELECT paydate FROM coins WHERE status IN ('owned', 'ordered', 'sale', 'sold', 'missing', 'duplicate', 'replacement') AND paydate<>'' AND paydate IS NOT NULL ORDER BY paydate LIMIT 1"
0 commit comments