alternate way to find series with missing books to use in series add drop-down - fixes issue with a new series with no bsl yet not showin in list
This commit is contained in:
2
TODO
2
TODO
@@ -1,3 +1,5 @@
|
|||||||
TODO:
|
TODO:
|
||||||
* book.parent is an array, not a dict - should change it over
|
* book.parent is an array, not a dict - should change it over
|
||||||
* need to use ORM for all bal, bsl, etc. seems to be causing race conditions and or 'timeouts'
|
* need to use ORM for all bal, bsl, etc. seems to be causing race conditions and or 'timeouts'
|
||||||
|
|
||||||
|
- sorting books on shelf. Up to Dune books --> is there an overarching series needed, and do it :)
|
||||||
|
|||||||
18
series.py
18
series.py
@@ -48,11 +48,21 @@ def CalcAvgRating(sid):
|
|||||||
return rating
|
return rating
|
||||||
|
|
||||||
def ListOfSeriesWithMissingBooks():
|
def ListOfSeriesWithMissingBooks():
|
||||||
with db.engine.connect() as conn:
|
from main import Book_Series_Link
|
||||||
res=conn.exec_driver_sql( "select id, title, num_books, count from ( select s.id, s.title, s.num_books, count(bsl.book_id) from series s left outer join book_series_link bsl on bsl.series_id=s.id where bsl.book_num is not null group by s.id) as foo where num_books > count")
|
|
||||||
|
rows = Series.query.outerjoin(Book_Series_Link).add_columns(Series.id,Series.title,Series.num_books,Book_Series_Link.book_num).order_by(Series.id,Book_Series_Link.book_num).all()
|
||||||
tmp=[]
|
tmp=[]
|
||||||
for row in res:
|
tots={}
|
||||||
tmp.append({'id': row[0], 'title': row[1]})
|
for row in rows:
|
||||||
|
if row.id not in tots:
|
||||||
|
tots[row.id]={ 'title': row.title, 'num_books': row.num_books, 'count': 0 }
|
||||||
|
if row.book_num is None:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
tots[row.id]['count'] += 1
|
||||||
|
for idx in tots:
|
||||||
|
if tots[idx]['num_books'] > tots[idx]['count']:
|
||||||
|
tmp.append( { 'id': idx, 'title': tots[idx]['title'] } )
|
||||||
return tmp
|
return tmp
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user