From 77899c2390cd1d62b9c08b174d884b55ea1453b4 Mon Sep 17 00:00:00 2001 From: evilhero Date: Fri, 2 Jan 2015 01:56:01 -0500 Subject: [PATCH] FIX:(#912) Updated fix to include issues that have trailing decimal places - whether on purpose or not, which was causing incomplete loading of these series --- mylar/helpers.py | 33 +++++++++++++++++++++++++++++---- mylar/importer.py | 10 +++++++--- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/mylar/helpers.py b/mylar/helpers.py index fb05e9b5..f3958ed3 100755 --- a/mylar/helpers.py +++ b/mylar/helpers.py @@ -573,7 +573,16 @@ def ComicSort(comicorder=None,sequence=None,imported=None): if sequence: # if it's on startup, load the sql into a tuple for use to avoid record-locking i = 0 - import db, logger + import logger + #if mylar.DBCHOICE == 'postgresql': + # import db_postgresql as db + # myDB = db.DBConnection() + # comicsort = myDB.select("SELECT * FROM comics ORDER BY ComicSortName COLLATE ?", [mylar.OS_LANG]) + #else: + # import db + # myDB = db.DBConnection() + # comicsort = myDB.select("SELECT * FROM comics ORDER BY ComicSortName COLLATE NOCASE") + import db myDB = db.DBConnection() comicsort = myDB.select("SELECT * FROM comics ORDER BY ComicSortName COLLATE NOCASE") comicorderlist = [] @@ -828,9 +837,15 @@ def issuedigits(issnum): if len(decis) == 1: decisval = int(decis) * 10 issaftdec = str(decisval) - if len(decis) >= 2: + elif len(decis) == 2: decisval = int(decis) issaftdec = str(decisval) + else: + decisval = decis + issaftdec = str(decisval) + #if there's a trailing decimal (ie. 1.50.) and it's either intentional or not, blow it away. + if issaftdec[-1:] == '.': + issaftdec = issaftdec[:-1] try: int_issnum = (int(issb4dec) * 1000) + (int(issaftdec) * 10) except ValueError: @@ -1060,12 +1075,22 @@ def havetotals(refreshit=None): comics = [] - myDB = db.DBConnection() if refreshit is None: + #if mylar.DBCHOICE == 'postgresql': + # import db_postgresql as db + # myDB = db.DBConnection() + # comiclist = myDB.select("SELECT * from comics order by ComicSortName COLLATE ?",[mylar.OS_LANG]) + #else: + # import db + # myDB = db.DBConnection() + # comiclist = myDB.select('SELECT * from comics order by ComicSortName COLLATE NOCASE') + import db + myDB = db.DBConnection() comiclist = myDB.select('SELECT * from comics order by ComicSortName COLLATE NOCASE') else: comiclist = [] + myDB = db.DBConnection() comicref = myDB.selectone("SELECT * from comics WHERE ComicID=?", [refreshit]).fetchone() #refreshit is the ComicID passed from the Refresh Series to force/check numerical have totals comiclist.append({"ComicID": comicref[0], @@ -1471,7 +1496,7 @@ def int_num(s): return int(s) except ValueError: return float(s) - + def listLibrary(): import db library = {} diff --git a/mylar/importer.py b/mylar/importer.py index e7378346..58356901 100755 --- a/mylar/importer.py +++ b/mylar/importer.py @@ -524,7 +524,6 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c latestiss = issuedata['LatestIssue'] latestdate = issuedata['LatestDate'] lastpubdate = issuedata['LastPubDate'] - #move the files...if imported is not empty & not futurecheck (meaning it's not from the mass importer.) if imported is None or imported == 'None' or imported == 'futurecheck': pass @@ -1120,7 +1119,7 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call cleanname = 'None' issid = str(firstval['Issue_ID']) issnum = firstval['Issue_Number'] - #print ("issnum: " + str(issnum)) + #logger.info("issnum: " + str(issnum)) issname = cleanname issdate = str(firstval['Issue_Date']) storedate = str(firstval['Store_Date']) @@ -1167,6 +1166,10 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call else: decisval = decis issaftdec = str(decisval) + #if there's a trailing decimal (ie. 1.50.) and it's either intentional or not, blow it away. + if issaftdec[-1:] == '.': + logger.fdebug('Trailing decimal located within issue number. Irrelevant to numbering. Obliterating.') + issaftdec = issaftdec[:-1] try: # int_issnum = str(issnum) int_issnum = (int(issb4dec) * 1000) + (int(issaftdec) * 10) @@ -1201,12 +1204,13 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call if len(issnum) == 1 and issnum.isalpha(): logger.fdebug('detected lone alpha issue. Attempting to figure this out.') break - logger.fdebug('[' + issno + '] Invalid numeric for issue - cannot be found. Ignoring.') + logger.fdebug('[' + issno + '] invalid numeric for issue - cannot be found. Ignoring.') issno = None tstord = None invchk = "true" break x+=1 + if tstord is not None and issno is not None: a = 0 ordtot = 0