Commit f9eeb13e authored by mitshel's avatar mitshel
Browse files

Добавлена сортировка по title, если отсутсвует ser_no в выводе книг посерии

parent 18bb17fb
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ drop table if exists bseries;
create table bseries(
ser_id INT not NULL,
book_id INT not NULL,
ser_no TINYINT UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY(book_id,ser_id),
INDEX(ser_id));
commit;
@@ -104,7 +105,7 @@ create table dbver(
ver varchar(5));
commit;

insert into dbver(ver) values("0.19");
insert into dbver(ver) values("0.20");
commit;
insert into authors(author_id,last_name,first_name) values(1,"Неизвестный Автор","");
commit;
+13 −2
Original line number Diff line number Diff line
@@ -164,8 +164,19 @@ class opdsScanner:
                   idx+=1
               for l in self.fb2parser.genre.getvalue():
                   self.opdsdb.addbgenre(book_id,self.opdsdb.addgenre(l.lower().strip(' \'\"')))
               for l in self.fb2parser.series.getattrs('name'):
                   self.opdsdb.addbseries(book_id,self.opdsdb.addseries(l.strip()))
#               for l in self.fb2parser.series.getattrs('name'):
#                   self.opdsdb.addbseries(book_id,self.opdsdb.addseries(l.strip()))
               for l in self.fb2parser.series.attrss:
                   ser_name=l.get('name')
                   if ser_name:
                      ser_id=self.opdsdb.addseries(ser_name.strip())
                      sser_no=l.get('number','0').strip()
                      if sser_no.isdigit():
                         ser_no=int(sser_no)
                      else:
                         ser_no=0
                      self.opdsdb.addbseries(book_id,ser_id,ser_no)

               if not self.cfg.SINGLE_COMMIT: self.opdsdb.commit()

            else:
+3 −1
Original line number Diff line number Diff line
@@ -310,10 +310,12 @@ class opdsClient():

    def entry_series(self,book_id):
        series=""
        for (ser,) in self.opdsdb.getseries(book_id):
        for (ser,ser_no) in self.opdsdb.getseries(book_id):
            if len(series)>0:
                  series+=', '
            series+=ser
            if ser_no > 0:
                  series += ' #' + str(ser_no)
        return series

    def entry_covers(self,cover,cover_type,book_id):
+6 −6
Original line number Diff line number Diff line
@@ -292,9 +292,9 @@ class opdsDatabase:
    cursor.close()
    return ser_id

  def addbseries(self, book_id, ser_id):
       sql=("insert into "+TBL_BSERIES+"(book_id,ser_id) VALUES(%s,%s)")
       data=(book_id,ser_id)
  def addbseries(self, book_id, ser_id, ser_no):
       sql=("insert into "+TBL_BSERIES+"(book_id,ser_id,ser_no) VALUES(%s,%s,%s)")
       data=(book_id,ser_id,ser_no)
       cursor=self.cnx.cursor()
       try:
         cursor.execute(sql,data)
@@ -421,7 +421,7 @@ class opdsDatabase:
    return rows

  def getseries(self,book_id):
    sql=("select ser from "+TBL_SERIES+" a, "+TBL_BSERIES+" b where b.ser_id=a.ser_id and b.book_id="+str(book_id))
    sql=("select a.ser, b.ser_no from "+TBL_SERIES+" a, "+TBL_BSERIES+" b where b.ser_id=a.ser_id and b.book_id="+str(book_id))
    cursor=self.cnx.cursor()
    cursor.execute(sql)
    rows=cursor.fetchall()
@@ -566,7 +566,7 @@ class opdsDatabase:
       "from "+TBL_BOOKS+" a "
       "left join "+TBL_BAUTHORS+" b on a.book_id=b.book_id "
       "left join "+TBL_BSERIES +" c on a.book_id=c.book_id "
       "where author_id=%s and ser_id=%s and a.avail!=0 "+dstr+" order by a.title "+limitstr)
       "where author_id=%s and ser_id=%s and a.avail!=0 "+dstr+" order by c.ser_no, a.title "+limitstr)
       data=(author_id,ser_id)
    else:
       sql=("select SQL_CALC_FOUND_ROWS a.book_id,a.filename,a.path,a.registerdate,a.title,a.annotation,a.docdate,a.format,a.filesize,a.cover,a.cover_type "
@@ -646,7 +646,7 @@ class opdsDatabase:
    else: dstr=' and a.doublicat=0 '
    if new_period==0: period=''
    else: period=" and (registerdate>now()-INTERVAL %s DAY)"%new_period
    sql="select SQL_CALC_FOUND_ROWS a.book_id,a.filename,a.path,a.registerdate,a.title,a.annotation,a.docdate,a.format,a.filesize,a.cover,a.cover_type from "+TBL_BOOKS+" a, "+TBL_BSERIES+" b where a.book_id=b.book_id and b.ser_id="+str(ser_id)+" and a.avail!=0 "+dstr+period+" order by a.title "+limitstr
    sql="select SQL_CALC_FOUND_ROWS a.book_id,a.filename,a.path,a.registerdate,a.title,a.annotation,a.docdate,a.format,a.filesize,a.cover,a.cover_type from "+TBL_BOOKS+" a, "+TBL_BSERIES+" b where a.book_id=b.book_id and b.ser_id="+str(ser_id)+" and a.avail!=0 "+dstr+period+" order by b.ser_no, a.title "+limitstr
    cursor=self.cnx.cursor()
    cursor.execute(sql)
    rows=cursor.fetchall()