fixed bug where when you remove a sub_book it left a whole in sub_book_num's, and rewrote to new sqlalchemy 2, all the direct sqls
This commit is contained in:
@@ -41,13 +41,15 @@ class SeriesForm(FlaskForm):
|
||||
delete = SubmitField('Delete' )
|
||||
|
||||
def CalcAvgRating(sid):
|
||||
res=db.engine.execute( f"select round(avg(to_number(r.name, '99')),1) as rating from book b, rating r, series s, book_series_link bsl where s.id={sid} and s.id = bsl.series_id and bsl.book_id = b.id and b.rating = r.id and r.name ~ E'^\\\\d+$'" )
|
||||
with db.engine.connect() as conn:
|
||||
res=conn.exec_driver_sql( f"select round(avg(to_number(r.name, '99')),1) as rating from book b, rating r, series s, book_series_link bsl where s.id={sid} and s.id = bsl.series_id and bsl.book_id = b.id and b.rating = r.id and r.name ~ E'^\\\\d+$'" )
|
||||
for row in res:
|
||||
rating = row.rating
|
||||
return rating
|
||||
|
||||
def ListOfSeriesWithMissingBooks():
|
||||
res=db.engine.execute("select id, title, num_books, count from ( select s.id, s.title, s.num_books, count(bsl.book_id) from series s, book_series_link bsl where s.id = bsl.series_id group by s.id ) as foo where num_books > count")
|
||||
with db.engine.connect() as conn:
|
||||
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, book_series_link bsl where s.id = bsl.series_id group by s.id ) as foo where num_books > count")
|
||||
tmp=[]
|
||||
for row in res:
|
||||
tmp.append({'id': row[0], 'title': row[1]})
|
||||
|
||||
Reference in New Issue
Block a user