Changeset 2266 for pykota/trunk/pykota/storages/sql.py
- Timestamp:
- 05/21/05 00:40:21 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/sql.py
r2222 r2266 124 124 def extractHistory(self, extractonly={}) : 125 125 """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 126 133 thefilter = self.createFilter(extractonly) 127 134 if thefilter : 128 135 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)) 129 139 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) 130 140 return self.prepareRawResult(result) 131 141 132 142 def getAllUsersNames(self) : 133 143 """Extracts all user names.""" … … 498 508 self.doModify("DELETE FROM printergroupsmembers WHERE groupid=%s AND printerid=%s" % (self.doQuote(pgroup.ident), self.doQuote(printer.ident))) 499 509 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) be foredate, 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.""" 502 512 query = "SELECT jobhistory.*,username,printername FROM jobhistory,users,printers WHERE users.id=userid AND printers.id=printerid" 503 513 where = [] … … 510 520 if billingcode is not None : 511 521 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)) 514 526 if where : 515 527 query += " AND %s" % " AND ".join(where)