def firmByNum(self): records = Record.getRecords() stats = dict() for rec in records: if rec.id_company in stats: stats[rec.id_company] = stats[rec.id_company] + 1 else: stats[rec.id_company] = 1 sortedStats = sorted(stats.items(), key = lambda kv: kv[1], reverse = True) return sortedStats
def firmByTime(self): records = Record.getRecords() stats = dict() for rec in records: if rec.id_company in stats: stats[rec.id_company] = stats[rec.id_company] + (rec.endParking - rec.startParking) else: stats[rec.id_company] = (rec.endParking - rec.startParking) sortedStats = sorted(stats.items(), key = lambda kv: kv[1], reverse = True) return sortedStats
def everyBox(self, dayCount): records = Record.getRecords() stats = dict() for rec in records: if rec.boxID in stats: stats[rec.boxID] = stats[rec.boxID] + (((rec.endParking - rec.startParking)/24)/dayCount) else: stats[rec.boxID] + (((rec.endParking - rec.startParking)/24)/dayCount) #ked to bude zle tak sorry sortedStats = sorted(stats.items(), key = lambda kv: kv[1], reverse = True) return sortedStats
def ztpByFirm(self): records = Record.getRecords() stats = dict() ztpBoxes = set() for box in FrameCarPark.boxes: if box.ztp: ztpBoxes.add(box.number) for rec in records: if rec.boxID in ztpBoxes: if rec.id_company in stats: stats[rec.id_company] = stats[rec.id_commpany] + (((rec.endParking - rec.startParking)/24)/dayCount) else: stats[rec.id_company] + (((rec.endParking - rec.startParking)/24)/dayCount) sortedStats = sorted(stats.items(), key = lambda kv: kv[1], reverse = True) return sortedStats
def boxInTime(self, dayCount, startRegion, endRegion): records = Record.getRecords() stats = dict() startParking = None endParking = None for rec in records: if rec.startParking < endRegion: if rec.endParking > startRegion: if rec.endParking > endRegion: endParking = endRegion else: endParking = rec.endParking if rec.startParking > startRegion: startParking = startRegion else: startParking = rec.startParking if rec.boxID in stats: stats[rec.boxID] = stats[rec.boxID] + (((endParking - startParking)/(endRegion - startRegion))/dayCount) else: stats[rec.boxID] + (((endParking - startParking)/(endRegion - startRegion))/dayCount) #ked to bude napiču tak sorry sortedStats = sorted(stats.items(), key = lambda kv: kv[1], reverse = True) return sortedStats