Esempio n. 1
0
    def _convertTTS(self, tts, carid, oldsum, rawsum):
        position = 1
        additions = list()

        for entry in tts.rows:
            entry.position = position
            position += 1
            if entry.carid == carid:
                entry.label = 'current'
                if oldsum is not None and oldsum > 0:
                    additions.append(
                        entry.copyWith(position='old',
                                       toptime=t3(oldsum),
                                       label='old'))
                if rawsum is not None and rawsum > 0:
                    additions.append(
                        entry.copyWith(position='raw',
                                       toptime=t3(rawsum),
                                       label='raw'))

        if additions:
            tts.rows.extend(additions)
            tts.rows.sort(key=lambda x: float(x.toptime))
            tts.rows.sort(key=lambda x: int(x.courses), reverse=True)

        return tts.rows
Esempio n. 2
0
	def _classlist(self, carid):
		(self.driver, self.car) = self.session.query(Driver,Car).join('cars').filter(Car.id==carid).first()
		if self.driver.alias and not config['nwrsc.private']:
			self.driver.firstname = self.driver.alias
			self.driver.lastname = ""
		self.announcer = self.session.query(AnnouncerData).filter(AnnouncerData.eventid==self.eventid).filter(AnnouncerData.carid==carid).first()
		if self.announcer is None:
			raise BeforePage('no announcer data')

		ret = []
		classdata = ClassData(self.session)
		savecourses = 0
		for res in getClassResultsShort(self.session, self.settings, self.event, classdata, self.car.classcode):
			ret.append(_extract(res, 'sum', 'pospoints', 'diffpoints', 'carid', 'firstname', 'lastname', 'indexstr', 'position', 'trophy', 'diff', 'courses'))
			if res.carid == carid:
				ret[-1]['label'] = "current"
				savecourses = ret[-1]['courses']

		if self.announcer.oldsum > 0:
			ret.append({'sum': t3(self.announcer.oldsum), 'firstname':self.driver.firstname, 'lastname':self.driver.lastname, 'position':'old', 'label':'old', 'courses':savecourses})
		if self.announcer.potentialsum > 0:
			ret.append({'sum': t3(self.announcer.potentialsum), 'firstname':self.driver.firstname, 'lastname':self.driver.lastname, 'position':'raw', 'label':'raw', 'courses':savecourses})
		ret.sort(key=lambda x: float(x['sum']))
		ret.sort(key=lambda x: int(x['courses']), reverse=True)
		return ret
Esempio n. 3
0
	def _champlist(self, carid):
		self.car = self.session.query(Car).get(carid)
		self.cls = self.session.query(Class).filter(Class.code==self.car.classcode).first()
		self.announcer = self.session.query(AnnouncerData).filter(AnnouncerData.eventid==self.eventid).filter(AnnouncerData.carid==carid).first()
		if self.announcer is None:
			raise BeforePage('no announcer data')

		ret = []
		pos = 1
		for res in getChampResults(self.session, self.settings, self.cls.code).get(self.cls.code, []):
			entry = dict()
			entry['points'] = t3(res.points.total)
			entry['carid'] = res.carid
			entry['driverid'] = res.id
			entry['firstname'] = res.firstname
			entry['lastname'] = res.lastname
			entry['events'] = res.events
			entry['position'] = pos
			ret.append(entry)
			pos += 1

			if res.id != self.car.driverid:
				continue
			
			entry['label'] = 'current'
			if res.points == res.pospoints:
				if self.announcer.oldpospoints > 0:
					entry = entry.copy()
					entry['position'] = "old"
					entry['label'] = "old"
					entry['points'] = res.pospoints.theory(self.eventid, self.announcer.oldpospoints)
					ret.append(entry)
				if self.announcer.potentialpospoints > 0:
					entry = entry.copy()
					entry['position'] = "raw"
					entry['label'] = "raw"
					entry['points'] = res.pospoints.theory(self.eventid, self.announcer.potentialpospoints)
					ret.append(entry)

			if res.points == res.diffpoints:
				if self.announcer.olddiffpoints > 0:
					entry = entry.copy()
					entry['position'] = "old"
					entry['label'] = "old"
					entry['points'] = t3(res.diffpoints.theory(self.eventid, self.announcer.olddiffpoints))
					ret.append(entry)
				if self.announcer.potentialdiffpoints > 0:
					entry = entry.copy()
					entry['position'] = "raw"
					entry['label'] = "raw"
					entry['points'] = t3(res.diffpoints.theory(self.eventid, self.announcer.potentialdiffpoints))
					ret.append(entry)

		ret.sort(key=lambda x: float(x['points']), reverse=True)
		return ret
Esempio n. 4
0
def loadTopCourseNetTimes(session, event, course, classdata, allruns=False):
	if allruns:
		sql = topCourseNetAll
	else:
		sql = topCourseNet

	ttl = TopTimesList("Top Index Times (Course %d)" % course, ['Name', 'Index', '', 'Time'], ['name', 'indexstr', 'indexvalue', 'toptime'])
	for row in session.execute(sql, params={'eventid':event.id, 'course':course}):
		entry = TopTimeEntry(row)
		entry.indexstr = classdata.getIndexStr(entry)
		entry.indexvalue = t3(classdata.getEffectiveIndex(entry))
		entry.toptime = t3(entry.toptime)
		ttl.add(entry)
	return ttl
Esempio n. 5
0
def loadTopNetTimes(session, event, classdata, allruns=False):
	if allruns:
		sql = topNetAll
		title = "Top Index Times (All)"
	else:
		sql = topNet
		title = "Top Index Times (Counted)"

	ttl = TopTimesList(title, ['Name', 'Class', 'Index', '', 'Time'], ['name', 'classcode', 'indexstr', 'indexvalue', 'toptime'])
	for row in session.execute(sql, params={'eventid':event.id}):
		entry = TopTimeEntry(row)
		entry.indexstr = classdata.getIndexStr(row)
		entry.indexvalue = t3(classdata.getEffectiveIndex(row))
		entry.toptime = t3(row.toptime)
		ttl.add(entry)
	return ttl
Esempio n. 6
0
    def _classlist(self, carid):
        (self.driver, self.car) = self.session.query(
            Driver, Car).join('cars').filter(Car.id == carid).first()
        if self.driver.alias and not config['nwrsc.private']:
            self.driver.firstname = self.driver.alias
            self.driver.lastname = ""
        self.announcer = self.session.query(AnnouncerData).filter(
            AnnouncerData.eventid == self.eventid).filter(
                AnnouncerData.carid == carid).first()
        if self.announcer is None:
            raise BeforePage('no announcer data')

        ret = []
        classdata = ClassData(self.session)
        savecourses = 0
        for res in getClassResultsShort(self.session, self.settings,
                                        self.event, classdata,
                                        self.car.classcode):
            ret.append(
                _extract(res, 'sum', 'pospoints', 'diffpoints', 'carid',
                         'firstname', 'lastname', 'indexstr', 'position',
                         'trophy', 'diff', 'courses'))
            if res.carid == carid:
                ret[-1]['label'] = "current"
                savecourses = ret[-1]['courses']

        if self.announcer.oldsum > 0:
            ret.append({
                'sum': t3(self.announcer.oldsum),
                'firstname': self.driver.firstname,
                'lastname': self.driver.lastname,
                'position': 'old',
                'label': 'old',
                'courses': savecourses
            })
        if self.announcer.potentialsum > 0:
            ret.append({
                'sum': t3(self.announcer.potentialsum),
                'firstname': self.driver.firstname,
                'lastname': self.driver.lastname,
                'position': 'raw',
                'label': 'raw',
                'courses': savecourses
            })
        ret.sort(key=lambda x: float(x['sum']))
        ret.sort(key=lambda x: int(x['courses']), reverse=True)
        return ret
Esempio n. 7
0
def _extract(obj, *keys):
	if type(obj) is dict:
		ret = dict([(k, obj[k]) for k in keys])
	else:
		ret = dict([(k, getattr(obj,k)) for k in keys])
	for k, v in ret.iteritems():
		if type(v) is float:
			ret[k] = t3(v)
	return ret
Esempio n. 8
0
def _extract(obj, *keys):
    if type(obj) is dict:
        ret = dict([(k, obj[k]) for k in keys])
    else:
        ret = dict([(k, getattr(obj, k)) for k in keys])
    for k, v in ret.iteritems():
        if type(v) is float:
            ret[k] = t3(v)
    return ret
Esempio n. 9
0
def loadTopSegRawTimes(session, event, course, seg):
	getcol = ", MIN(r.seg%d) as toptime " % (seg)
	topSegRaw = top1 + getcol + top2 + " and r.course=:course and r.seg%d > %d group by r.carid order by toptime " % (seg, event.getSegments()[seg-1])

	ttl = TopTimesList("Top Segment Times (Course %d)" % course, ['Name', 'Class', 'Time'], ['name', 'classcode', 'toptime'])
	for row in session.execute(topSegRaw, params={'eventid':event.id, 'course':course}):
		entry = TopTimeEntry(row)
		entry.toptime = t3(entry.toptime)
		ttl.add(entry)
	return ttl
Esempio n. 10
0
	def _convertTTS(self, tts, carid, oldsum, rawsum):
		position = 1
		additions = list()
		
		for entry in tts.rows:
			entry.position = position
			position += 1
			if entry.carid == carid:
				entry.label = 'current'
				if oldsum is not None and oldsum > 0:
					additions.append(entry.copyWith(position='old', toptime=t3(oldsum), label='old'))
				if rawsum is not None and rawsum > 0:
					additions.append(entry.copyWith(position='raw', toptime=t3(rawsum), label='raw'))

		if additions:
			tts.rows.extend(additions)
			tts.rows.sort(key=lambda x: float(x.toptime))
			tts.rows.sort(key=lambda x: int(x.courses), reverse=True)

		return tts.rows
Esempio n. 11
0
def loadTopCourseRawTimes(session, event, course, classdata, allruns=False):
	if allruns:
		sql = topCourseRawAll
	else:
		sql = topCourseRaw

	ttl = TopTimesList("Top Times (Course %d)" % course, ['Name', 'Class', 'Time'], ['name', 'classcode', 'toptime'])
	for row in session.execute(sql, params={'eventid':event.id, 'course':course, 'conepen':event.conepen, 'gatepen':event.gatepen}):
		entry = TopTimeEntry(row)
		entry.toptime = t3(entry.toptime)
		ttl.add(entry)
	return ttl
Esempio n. 12
0
    def _champlist(self, carid):
        self.car = self.session.query(Car).get(carid)
        self.cls = self.session.query(Class).filter(
            Class.code == self.car.classcode).first()
        self.announcer = self.session.query(AnnouncerData).filter(
            AnnouncerData.eventid == self.eventid).filter(
                AnnouncerData.carid == carid).first()
        if self.announcer is None:
            raise BeforePage('no announcer data')

        ret = []
        pos = 1
        for res in getChampResults(self.session, self.settings,
                                   self.cls.code).get(self.cls.code, []):
            entry = dict()
            entry['points'] = t3(res.points.total)
            entry['carid'] = res.carid
            entry['driverid'] = res.id
            entry['firstname'] = res.firstname
            entry['lastname'] = res.lastname
            entry['events'] = res.events
            entry['position'] = pos
            ret.append(entry)
            pos += 1

            if res.id != self.car.driverid:
                continue

            entry['label'] = 'current'
            if res.points == res.pospoints:
                if self.announcer.oldpospoints > 0:
                    entry = entry.copy()
                    entry['position'] = "old"
                    entry['label'] = "old"
                    entry['points'] = res.pospoints.theory(
                        self.eventid, self.announcer.oldpospoints)
                    ret.append(entry)
                if self.announcer.potentialpospoints > 0:
                    entry = entry.copy()
                    entry['position'] = "raw"
                    entry['label'] = "raw"
                    entry['points'] = res.pospoints.theory(
                        self.eventid, self.announcer.potentialpospoints)
                    ret.append(entry)

            if res.points == res.diffpoints:
                if self.announcer.olddiffpoints > 0:
                    entry = entry.copy()
                    entry['position'] = "old"
                    entry['label'] = "old"
                    entry['points'] = t3(
                        res.diffpoints.theory(self.eventid,
                                              self.announcer.olddiffpoints))
                    ret.append(entry)
                if self.announcer.potentialdiffpoints > 0:
                    entry = entry.copy()
                    entry['position'] = "raw"
                    entry['label'] = "raw"
                    entry['points'] = t3(
                        res.diffpoints.theory(
                            self.eventid, self.announcer.potentialdiffpoints))
                    ret.append(entry)

        ret.sort(key=lambda x: float(x['points']), reverse=True)
        return ret