More cleanups.
This commit is contained in:
parent
53abd4e151
commit
d200af238c
23
aacstats.py
23
aacstats.py
@ -81,7 +81,7 @@ def read_db(listing=None, event=None, person=None, licence=None, search=dict(),
|
|||||||
close = ''
|
close = ''
|
||||||
where = 'WHERE club LIKE "AAC"'
|
where = 'WHERE club LIKE "AAC"'
|
||||||
group = ''
|
group = ''
|
||||||
order = 'date DESC, event, position'
|
order = 'date DESC, event, distance DESC, position'
|
||||||
limit = 'LIMIT {},{}'.format(start, show)
|
limit = 'LIMIT {},{}'.format(start, show)
|
||||||
if show == -1:
|
if show == -1:
|
||||||
limit = ''
|
limit = ''
|
||||||
@ -146,21 +146,28 @@ def read_db(listing=None, event=None, person=None, licence=None, search=dict(),
|
|||||||
if listing:
|
if listing:
|
||||||
if listing == 'races':
|
if listing == 'races':
|
||||||
select = 'event, date'
|
select = 'event, date'
|
||||||
group = 'GROUP BY event'
|
group = 'GROUP BY event, date'
|
||||||
|
order = 'date DESC, event'
|
||||||
elif listing == 'runners':
|
elif listing == 'runners':
|
||||||
select = 'CONCAT_WS(" ", name, surname) person, FORMAT(SUM(distance),0) total'
|
select = 'CONCAT_WS(" ", name, surname) person, FORMAT(SUM(distance),0) total'
|
||||||
where += ' AND CONCAT_WS(" ", name, surname) NOT LIKE "%NO RETURN%"'
|
where += ' AND CONCAT_WS(" ", name, surname) NOT LIKE "%no return%"'
|
||||||
where += ' AND CONCAT_WS(" ", name, surname) NOT LIKE "%BLANK CARD%"'
|
where += ' AND CONCAT_WS(" ", name, surname) NOT LIKE "%no card%"'
|
||||||
|
where += ' AND CONCAT_WS(" ", name, surname) NOT LIKE "%blank card%"'
|
||||||
|
where += ' AND CONCAT_WS(" ", name, surname) NOT LIKE "%disqualified%"'
|
||||||
group = 'GROUP BY CONCAT_WS(" ", name, surname)'
|
group = 'GROUP BY CONCAT_WS(" ", name, surname)'
|
||||||
order = 'SUM(distance) DESC, surname'
|
order = 'SUM(distance) DESC, CONCAT_WS(" ", name, surname)'
|
||||||
elif listing == 'rankings':
|
elif listing == 'rankings':
|
||||||
select = 'CONCAT_WS(" ", name, surname) person, SUM(position) positions, COUNT(event) races, SUM(position)/COUNT(event) podiums, FORMAT(SUM(position)/COUNT(event),1) score'
|
select = 'CONCAT_WS(" ", name, surname) person, SUM(position) positions, COUNT(event) races, SUM(position)/COUNT(event) podiums, FORMAT(SUM(position)/COUNT(event),1) score'
|
||||||
|
where += ' AND CONCAT_WS(" ", name, surname) NOT LIKE "%no return%"'
|
||||||
|
where += ' AND CONCAT_WS(" ", name, surname) NOT LIKE "%no card%"'
|
||||||
|
where += ' AND CONCAT_WS(" ", name, surname) NOT LIKE "%blank card%"'
|
||||||
|
where += ' AND CONCAT_WS(" ", name, surname) NOT LIKE "%disqualified%"'
|
||||||
group = 'GROUP BY CONCAT_WS(" ", name, surname)'
|
group = 'GROUP BY CONCAT_WS(" ", name, surname)'
|
||||||
order = 'podiums, races DESC'
|
order = 'podiums, races DESC'
|
||||||
elif listing == 'licence':
|
elif listing == 'licence':
|
||||||
select = 'licence, date, CONCAT_WS(" ", name, surname) person'
|
select = 'licence, date, CONCAT_WS(" ", name, surname) person'
|
||||||
group = 'GROUP BY licence'
|
group = 'GROUP BY licence, CONCAT_WS(" ", name, surname)'
|
||||||
order = 'surname, date DESC'
|
order = 'CONCAT_WS(" ", name, surname), date DESC'
|
||||||
|
|
||||||
|
|
||||||
sql = 'SELECT {} FROM `results` {} {} ORDER BY {} {} {};'.format(select, where, group, order, limit, close)
|
sql = 'SELECT {} FROM `results` {} {} ORDER BY {} {} {};'.format(select, where, group, order, limit, close)
|
||||||
@ -176,11 +183,9 @@ def read_db(listing=None, event=None, person=None, licence=None, search=dict(),
|
|||||||
close = ') AS races'
|
close = ') AS races'
|
||||||
elif listing == 'runners':
|
elif listing == 'runners':
|
||||||
select = 'COUNT(*) FROM ( SELECT COUNT(name)'
|
select = 'COUNT(*) FROM ( SELECT COUNT(name)'
|
||||||
group = 'GROUP BY CONCAT_WS(" ", name, surname)'
|
|
||||||
close = ') AS runners'
|
close = ') AS runners'
|
||||||
elif listing == 'rankings':
|
elif listing == 'rankings':
|
||||||
select = 'COUNT(*) FROM ( SELECT COUNT(name)'
|
select = 'COUNT(*) FROM ( SELECT COUNT(name)'
|
||||||
group = 'GROUP BY CONCAT_WS(" ", name, surname)'
|
|
||||||
close = ') AS rankings'
|
close = ') AS rankings'
|
||||||
elif listing == 'licence':
|
elif listing == 'licence':
|
||||||
select = 'COUNT(*) FROM ( SELECT COUNT(licence)'
|
select = 'COUNT(*) FROM ( SELECT COUNT(licence)'
|
||||||
|
Loading…
Reference in New Issue
Block a user