Commit 5f57e156 authored by mitshel's avatar mitshel
Browse files

Добавлен индекс для поля avail таблицы books (статистика на первой странице...

Добавлен индекс для поля avail таблицы books (статистика на первой странице теперь рассчитывается быстрее)
Изменен скрипт для получения статистики dbinfo - устранены недочеты, которые могли проявлятся при некоторых обстоятельствах.
В скрипт dbinfo доавлено вычисление количества жанров
parent a83baa88
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -22,7 +22,8 @@ doublicat INT not null DEFAULT 0,
avail INT not null DEFAULT 0,
PRIMARY KEY(book_id),
KEY(filename),
KEY(title,format,filesize));
KEY(title,format,filesize),
KEY(avail));
commit;

drop table if exists catalogs;
+4 −4
Original line number Diff line number Diff line
@@ -87,22 +87,22 @@ def main_menu():
   enc_print('<link href="'+cfg.CGI_PATH+'?searchTerm={searchTerms}" rel="search" type="application/atom+xml" />')
   enc_print('<entry>')
   enc_print('<title>По каталогам</title>')
   enc_print('<content type="text">Каталогов: %s, книг: %s.</content>'%(dbinfo[2][0],dbinfo[0][0]))
   enc_print('<content type="text">Каталогов: %s, книг: %s.</content>'%(dbinfo[2][1],dbinfo[0][1]))
   enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id=01"/>')
   enc_print('<id>id:01</id></entry>')
   enc_print('<entry>')
   enc_print('<title>По авторам</title>')
   enc_print('<content type="text">Авторов: %s, книг: %s.</content>'%(dbinfo[1][0],dbinfo[0][0]))
   enc_print('<content type="text">Авторов: %s, книг: %s.</content>'%(dbinfo[1][1],dbinfo[0][1]))
   enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id='+am+'02"/>')
   enc_print('<id>id:02</id></entry>')
   enc_print('<entry>')
   enc_print('<title>По наименованию</title>')
   enc_print('<content type="text">Авторов: %s, книг: %s.</content>'%(dbinfo[1][0],dbinfo[0][0]))
   enc_print('<content type="text">Авторов: %s, книг: %s.</content>'%(dbinfo[1][1],dbinfo[0][1]))
   enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id='+am+'03"/>')
   enc_print('<id>id:03</id></entry>')
   enc_print('<entry>')
   enc_print('<title>По Жанрам</title>')
   enc_print('<content type="text">Авторов: %s, книг: %s.</content>'%(dbinfo[1][0],dbinfo[0][0]))
   enc_print('<content type="text">Жанров: %s, книг: %s.</content>'%(dbinfo[3][1],dbinfo[0][1]))
   enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id=04"/>')
   enc_print('<id>id:04</id></entry>')
   enc_print('<entry>')
+1 −1
Original line number Diff line number Diff line
@@ -501,7 +501,7 @@ class opdsDatabase:
       dstr=''
    else:
       dstr='and doublicat=0'
    sql="select count(*) from %s where avail!=0 %s union select count(*) from %s union select count(*) from %s"%(TBL_BOOKS,dstr,TBL_AUTHORS,TBL_CATALOGS)
    sql="select 1 s, count(avail) from %s where avail!=0 %s union all select 2 s, count(author_id) from %s union all select 3 s, count(cat_id) from %s union all select 4 s, count(genre_id) from %s order by s"%(TBL_BOOKS,dstr,TBL_AUTHORS,TBL_CATALOGS,TBL_GENRES)
    cursor=self.cnx.cursor()
    cursor.execute(sql)
    rows=cursor.fetchall()