def signatureHistory (self, params, connection): self.connection = connection params.productdims_id = (self.context['productVersionCache'] .getId(params.product, params.version)) #logger.debug('signatureHistory %s %s', params, self.connection) params.startDate = params.endDate - params.duration params.stepSize = dtutil.timeDeltaToSeconds(params.duration / params.steps) signatureHistory = self.fetchSignatureHistory(params) listOfEntries = [] for bucket, total in self.fetchTotalsForRange(params): #logger.debug('signatureHistory fetchTotalsForRange %s %s', bucket, total) d = { 'date': str(dt.timedelta(seconds=params.stepSize * bucket) + params.startDate), 'count': signatureHistory.setdefault(bucket, 0), 'percentOfTotal': signatureHistory.setdefault(bucket, 0) / float(total), } listOfEntries.append(d) #logger.debug(listOfEntries) result = { 'signatureHistory': listOfEntries, 'signature': params.signature, 'start_date': str(params.startDate), 'end_date': str(params.endDate), } #logger.debug(result) return result
def signatureHistory (self, parameters, connection): self.connection = connection #logger.debug('signatureHistory %s %s', parameters, self.connection) parameters.startDate = parameters.endDate - parameters.duration parameters.stepSize = dtutil.timeDeltaToSeconds(parameters.duration / parameters.steps) listOfEntries = [] for date, count, percent in self.fetchSigHistory(parameters): #logger.debug('signatureHistory fetchTotalsForRange %s %s', bucket, total) d = { 'date': date.isoformat(), 'count': count, 'percentOfTotal': percent, } listOfEntries.append(d) #logger.debug(listOfEntries) result = { 'signatureHistory': listOfEntries, 'signature': parameters.signature, 'start_date': parameters.startDate.isoformat(), 'end_date': parameters.endDate.isoformat(), } #logger.debug(result) return result