Commit ad795903 authored by mitshel's avatar mitshel
Browse files

В меню новинок для ускорения выдачи теперь не рассчитывается количество Авторов, Серий и жанров

parent 55d30e15
Loading
Loading
Loading
Loading
+3 −15
Original line number Diff line number Diff line
@@ -140,7 +140,6 @@ def main_menu():
      enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id=08"/>')
      enc_print('<id>id:08</id></entry>')


def new_menu():
   if cfg.ALPHA: am='30'
   else: am=''
@@ -152,17 +151,17 @@ def new_menu():
   enc_print('<id>id:03:news</id></entry>')
   enc_print('<entry>')
   enc_print('<title>Новинки по авторам</title>')
   enc_print('<content type="text">Авторов новинок: %s.</content>'%newinfo[1][1])
#   enc_print('<content type="text">Авторов новинок: %s.</content>'%newinfo[1][1])
   enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id='+am+'02&amp;news=1"/>')
   enc_print('<id>id:02:news</id></entry>')
   enc_print('<entry>')
   enc_print('<title>Новинки по Жанрам</title>')
   enc_print('<content type="text">Жанров новинок: %s.</content>'%newinfo[2][1])
#   enc_print('<content type="text">Жанров новинок: %s.</content>'%newinfo[2][1])
   enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id=04&amp;news=1"/>')
   enc_print('<id>id:04:news</id></entry>')
   enc_print('<entry>')
   enc_print('<title>Новинки по Сериям</title>')
   enc_print('<content type="text">Серий новинок: %s.</content>'%newinfo[3][1])
#   enc_print('<content type="text">Серий новинок: %s.</content>'%newinfo[3][1])
   enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id='+am+'06&amp;news=1"/>')
   enc_print('<id>id:06:news</id></entry>')

@@ -569,17 +568,6 @@ if type_value==24:
elif type_value==5:
   header()
   new_menu()
#   for (book_id,book_name,book_path,reg_date,book_title,annotation,docdate,format,fsize,cover,cover_type) in opdsdb.getlastbooks(cfg.MAXITEMS):
#       id='90'+str(book_id)
#       entry_start()
#       entry_head(book_title, reg_date, id_value)
#       entry_link_book(book_id,format)
#       entry_covers(cover,cover_type,book_id)
#       authors=entry_authors(opdsdb,book_id,True)
#       genres=entry_genres(opdsdb,book_id)
#       series=entry_series(opdsdb,book_id)
#       entry_content2(annotation,book_title,authors,genres,book_name,fsize,docdate,series)
#       entry_finish()
   footer()

#########################################################
+15 −15
Original line number Diff line number Diff line
@@ -758,26 +758,26 @@ class opdsDatabase:
    return rows

  def getnewinfo(self,doublicates=True,new_period=0):
#    if doublicates: dstr=''
#    else: dstr='and doublicat=0'
#
#    if new_period==0: period=''
#    else: period='and registerdate>now()-INTERVAL %s DAY'%new_period
#
#    sql1="select 1 s, count(avail) from %s where avail!=0 %s %s"%(TBL_BOOKS,dstr,period)
    if doublicates: dstr=''
    else: dstr='and doublicat=0'

    if new_period==0: period=''
    else: period='and registerdate>now()-INTERVAL %s DAY'%new_period

    sql="select 1 s, count(avail) from %s where avail!=0 %s %s"%(TBL_BOOKS,dstr,period)
#    sql2="select 2 s, count(*) from (select b.author_id from %s b left join %s c on b.book_id=c.book_id where c.avail!=0 %s group by b.author_id) a1"%(TBL_BAUTHORS, TBL_BOOKS, period)
#    sql3="select 3 s, count(*) from (select b.genre_id from %s b left join %s c on b.book_id=c.book_id where c.avail!=0 %s group by b.genre_id) a2"%(TBL_BGENRES, TBL_BOOKS, period)
#    sql4="select 4 s, count(*) from (select b.ser_id from %s b left join %s c on b.book_id=c.book_id where c.avail!=0 %s group by b.ser_id) a3"%(TBL_BSERIES, TBL_BOOKS, period)
#    sql=sql1+" union all "+sql2+" union all "+sql3+" union all "+sql4+" order by s"
#    cursor=self.cnx.cursor()
#    cursor.execute(sql)
#    rows=cursor.fetchall()

    sql="call sp_newinfo(%s)"%new_period
    cursor=self.cnx.cursor()
    cursor.callproc('sp_newinfo',(new_period,))
    for results in cursor.stored_results():
        rows=results.fetchall()
    cursor.execute(sql)
    rows=cursor.fetchall()

#    sql="call sp_newinfo(%s)"%new_period
#    cursor=self.cnx.cursor()
#    cursor.callproc('sp_newinfo',(new_period,))
#    for results in cursor.stored_results():
#        rows=results.fetchall()

    cursor.close
    return rows