Show
Ignore:
Timestamp:
05/21/05 00:40:21 (19 years ago)
Author:
jerome
Message:

Now dumpykota and dumpykota.cgi accept start= and end=
to specify the starting and ending dates when dumping the
history.
Syntax allowed is :

start|end=YYYY[MM[DD[hh[mm[ss]]]]]

and this is REALLY powerful !

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/sql.py

    r2222 r2266  
    124124    def extractHistory(self, extractonly={}) : 
    125125        """Extracts all jobhistory records.""" 
     126        startdate = extractonly.get("start") 
     127        enddate = extractonly.get("end") 
     128        for limit in ("start", "end") : 
     129            try : 
     130                del extractonly[limit] 
     131            except KeyError :     
     132                pass 
    126133        thefilter = self.createFilter(extractonly) 
    127134        if thefilter : 
    128135            thefilter = "AND %s" % thefilter 
     136        (startdate, enddate) = self.cleanDates(startdate, enddate) 
     137        if startdate and enddate :  
     138            thefilter = "%s AND jobdate>=%s AND jobdate<=%s" % (thefilter, self.doQuote(startdate), self.doQuote(enddate)) 
    129139        result = self.doRawSearch("SELECT users.username,printers.printername,jobhistory.* FROM users,printers,jobhistory WHERE users.id=jobhistory.userid AND printers.id=jobhistory.printerid %s ORDER BY jobhistory.id ASC" % thefilter) 
    130140        return self.prepareRawResult(result) 
    131          
     141             
    132142    def getAllUsersNames(self) :     
    133143        """Extracts all user names.""" 
     
    498508        self.doModify("DELETE FROM printergroupsmembers WHERE groupid=%s AND printerid=%s" % (self.doQuote(pgroup.ident), self.doQuote(printer.ident))) 
    499509         
    500     def retrieveHistory(self, user=None, printer=None, datelimit=None, hostname=None, billingcode=None, limit=100) : 
    501         """Retrieves all print jobs for user on printer (or all) before date, limited to first 100 results.""" 
     510    def retrieveHistory(self, user=None, printer=None, hostname=None, billingcode=None, limit=100, start=None, end=None) : 
     511        """Retrieves all print jobs for user on printer (or all) between start and end date, limited to first 100 results.""" 
    502512        query = "SELECT jobhistory.*,username,printername FROM jobhistory,users,printers WHERE users.id=userid AND printers.id=printerid" 
    503513        where = [] 
     
    510520        if billingcode is not None :     
    511521            where.append("billingcode=%s" % self.doQuote(self.userCharsetToDatabase(billingcode))) 
    512         if datelimit is not None :     
    513             where.append("jobdate<=%s" % self.doQuote(datelimit)) 
     522        if start is not None :     
     523            where.append("jobdate>=%s" % self.doQuote(start)) 
     524        if end is not None :     
     525            where.append("jobdate<=%s" % self.doQuote(end)) 
    514526        if where :     
    515527            query += " AND %s" % " AND ".join(where)