Add new lists, restructure navigation
This commit is contained in:
parent
5b7a78223e
commit
5a2686f6f7
188
aacstats.py
188
aacstats.py
@ -1,53 +1,91 @@
|
|||||||
from flask import Flask, request, render_template, url_for
|
from flask import Flask, abort, request, render_template, url_for
|
||||||
import math
|
import math
|
||||||
import MySQLdb
|
import MySQLdb
|
||||||
import MySQLdb.cursors
|
import MySQLdb.cursors
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
PAGE_SIZE=20
|
||||||
|
# TODO: Search
|
||||||
|
|
||||||
|
def now():
|
||||||
|
# TODO: If it's January and no races have been run this year, return last year
|
||||||
|
return dt.datetime.now()
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
@app.route('/list')
|
||||||
|
@app.route('/list/<title>') # title = { races, rankings, runners, licence }
|
||||||
|
@app.route('/list/<title>/<int:year>')
|
||||||
|
def list(title=None, year=None):
|
||||||
|
''' Set defaults for the index page '''
|
||||||
|
if year is None and title is None:
|
||||||
|
year = now().year
|
||||||
|
title = 'runners'
|
||||||
|
if title not in ( 'races', 'rankings', 'runners', 'licence', ):
|
||||||
|
abort(404)
|
||||||
start = int(request.args.get('start', '0'))
|
start = int(request.args.get('start', '0'))
|
||||||
limit = int(request.args.get('limit', '10'))
|
limit = int(request.args.get('limit', PAGE_SIZE))
|
||||||
results = read_db(start, limit)
|
results = read_db(start, limit, listing=title, year=year)
|
||||||
total = int(total_entries())
|
return render_template('list-'+title+'.html', ltype='listing', title=title, year=year,
|
||||||
return render_template('index.html', ltype='index', request=request, start=start, limit=limit, results=results, total=total)
|
results=results, start=start, limit=limit,
|
||||||
|
request=request, now=now(), PAGE_SIZE=PAGE_SIZE)
|
||||||
|
@app.route('/all')
|
||||||
|
@app.route('/all/<int:year>')
|
||||||
|
@app.route('/all/<int:year>/<title>') # this does nothing, and is simply here to prevent title from being added to the query string
|
||||||
|
def index(title=None, year=None):
|
||||||
|
start = int(request.args.get('start', '0'))
|
||||||
|
limit = int(request.args.get('limit', PAGE_SIZE))
|
||||||
|
results = read_db(start, limit, year=year)
|
||||||
|
return render_template('index.html', ltype='index', year=year,
|
||||||
|
results=results, start=start, limit=limit,
|
||||||
|
request=request, now=now(), PAGE_SIZE=PAGE_SIZE)
|
||||||
|
|
||||||
@app.route('/race/<year>/<title>')
|
|
||||||
def race(start=0, year=None, title=None):
|
@app.route('/race/<int:year>/<title>')
|
||||||
|
def race(year=None, title=None):
|
||||||
start = int(request.args.get('start', '0'))
|
start = int(request.args.get('start', '0'))
|
||||||
limit = int(request.args.get('limit', '10'))
|
limit = int(request.args.get('limit', PAGE_SIZE))
|
||||||
total = int(total_entries(event=title, year=year))
|
|
||||||
results = read_db(start, limit, event=title, year=year)
|
results = read_db(start, limit, event=title, year=year)
|
||||||
return render_template('index.html', ltype='race', title=title, year=year, request=request, start=start, limit=limit, results=results, total=total)
|
return render_template('index.html', ltype='race', title=title, year=year,
|
||||||
|
results=results, start=start, limit=limit,
|
||||||
|
request=request, now=now(), PAGE_SIZE=PAGE_SIZE)
|
||||||
|
|
||||||
@app.route('/person/<title>')
|
@app.route('/person/<title>')
|
||||||
@app.route('/person/<title>/<year>')
|
@app.route('/person/<title>/<int:year>')
|
||||||
def person(start=0, title=None, year=None):
|
def person(title=None, year=None):
|
||||||
start = int(request.args.get('start', '0'))
|
start = int(request.args.get('start', '0'))
|
||||||
limit = int(request.args.get('limit', '10'))
|
limit = int(request.args.get('limit', PAGE_SIZE))
|
||||||
total = int(total_entries(person=title, year=year))
|
|
||||||
results = read_db(start, limit, person=title, year=year)
|
results = read_db(start, limit, person=title, year=year)
|
||||||
return render_template('index.html', ltype='person', title=title, year=year, request=request, start=start, limit=limit, results=results, total=total)
|
return render_template('index.html', ltype='person', title=title, year=year,
|
||||||
|
results=results, start=start, limit=limit,
|
||||||
|
request=request, now=now(), PAGE_SIZE=PAGE_SIZE)
|
||||||
|
|
||||||
@app.route('/licence/<year>/<title>')
|
@app.route('/licence/<int:year>')
|
||||||
def licence(start=0, year=dt.datetime.now().year, title=None):
|
@app.route('/licence/<int:year>/<title>')
|
||||||
|
def licence(year=now().year, title=None):
|
||||||
start = int(request.args.get('start', '0'))
|
start = int(request.args.get('start', '0'))
|
||||||
limit = int(request.args.get('limit', '10'))
|
limit = int(request.args.get('limit', PAGE_SIZE))
|
||||||
total = int(total_entries(licence=title, year=year))
|
|
||||||
results = read_db(start, limit, licence=title, year=year)
|
results = read_db(start, limit, licence=title, year=year)
|
||||||
return render_template('index.html', ltype='licence', title=title, year=year, request=request, start=start, limit=limit, results=results, total=total)
|
return render_template('index.html', ltype='licence', title=title, year=year,
|
||||||
|
results=results, start=start, limit=limit,
|
||||||
|
request=request, now=now(), PAGE_SIZE=PAGE_SIZE)
|
||||||
|
|
||||||
|
|
||||||
def read_db(start=0, limit=10, person=None, licence=None, event=None, year=None):
|
def read_db(start=0, limit=PAGE_SIZE, listing=None, event=None, person=None, licence=None, year=None):
|
||||||
db = MySQLdb.connect(user = 'aac', passwd = 'saOAcCWHg4LaoSSA', db = 'AAC', cursorclass = MySQLdb.cursors.DictCursor)
|
db = MySQLdb.connect(user = 'aac', passwd = 'saOAcCWHg4LaoSSA', db = 'AAC', cursorclass = MySQLdb.cursors.DictCursor)
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
where = 'club LIKE "AAC"'
|
|
||||||
if person:
|
count = 0
|
||||||
where += ' AND CONCAT_WS(" ", name, surname) LIKE "{}"'.format(person)
|
|
||||||
|
select = '*'
|
||||||
|
where = 'WHERE club LIKE "AAC"'
|
||||||
|
group = ''
|
||||||
|
order = 'date DESC, event, position'
|
||||||
|
close = ''
|
||||||
if event:
|
if event:
|
||||||
where += ' AND event LIKE "{}"'.format(event)
|
where += ' AND event LIKE "{}"'.format(event)
|
||||||
|
if person:
|
||||||
|
where += ' AND CONCAT_WS(" ", name, surname) LIKE "{}"'.format(person)
|
||||||
if licence:
|
if licence:
|
||||||
where += ' AND licence LIKE "{}"'.format(licence)
|
where += ' AND licence LIKE "{}"'.format(licence)
|
||||||
if year:
|
if year:
|
||||||
@ -56,51 +94,77 @@ def read_db(start=0, limit=10, person=None, licence=None, event=None, year=None)
|
|||||||
firstdate = firstdate.replace(year=int(year))
|
firstdate = firstdate.replace(year=int(year))
|
||||||
lastdate = lastdate.replace(year=int(year))
|
lastdate = lastdate.replace(year=int(year))
|
||||||
where += ' AND date > "{}" AND date < "{}"'.format(firstdate, lastdate)
|
where += ' AND date > "{}" AND date < "{}"'.format(firstdate, lastdate)
|
||||||
sql = 'SELECT * FROM `results` WHERE {} ORDER BY date DESC, event, position LIMIT {},{};'.format(where, start, limit)
|
|
||||||
c.execute(sql)
|
|
||||||
results = c.fetchall()
|
|
||||||
return results
|
|
||||||
|
|
||||||
@app.template_filter('total_entries')
|
if listing:
|
||||||
def total_entries(person=None, licence=None, event=None, year=None):
|
if listing == 'races':
|
||||||
db = MySQLdb.connect(user = 'aac', passwd = 'saOAcCWHg4LaoSSA', db = 'AAC', cursorclass = MySQLdb.cursors.DictCursor)
|
select = 'event, date'
|
||||||
c = db.cursor()
|
group = 'GROUP BY event'
|
||||||
where = 'club LIKE "AAC"'
|
elif listing == 'runners':
|
||||||
if person:
|
select = 'CONCAT_WS(" ", name, surname) person, FORMAT(SUM(distance),0) total'
|
||||||
where += ' AND CONCAT_WS(" ", name, surname) LIKE "{}"'.format(person)
|
where += ' AND CONCAT_WS(" ", name, surname) NOT LIKE "%NO RETURN%"'
|
||||||
if event:
|
where += ' AND CONCAT_WS(" ", name, surname) NOT LIKE "%BLANK CARD%"'
|
||||||
where += ' AND event LIKE "{}"'.format(event)
|
group = 'GROUP BY CONCAT_WS(" ", name, surname)'
|
||||||
if licence:
|
order = 'SUM(distance) DESC, surname'
|
||||||
where += ' AND licence LIKE "{}"'.format(licence)
|
elif listing == 'rankings':
|
||||||
if year:
|
select = 'CONCAT_WS(" ", name, surname) person, SUM(position) positions, COUNT(event) races, SUM(position)/COUNT(event) podiums, FORMAT(SUM(position)/COUNT(event),1) score'
|
||||||
firstdate = dt.datetime.min
|
group = 'GROUP BY CONCAT_WS(" ", name, surname)'
|
||||||
lastdate = dt.datetime.max
|
order = 'podiums, races DESC'
|
||||||
firstdate = firstdate.replace(year=int(year))
|
elif listing == 'licence':
|
||||||
lastdate = lastdate.replace(year=int(year))
|
select = 'licence, date, CONCAT_WS(" ", name, surname) person'
|
||||||
where += ' AND date > "{}" AND date < "{}"'.format(firstdate, lastdate)
|
group = 'GROUP BY licence'
|
||||||
sql = 'SELECT COUNT(*) FROM `results` WHERE {}'.format(where)
|
order = 'surname, date DESC'
|
||||||
|
|
||||||
|
sql = 'SELECT {} FROM `results` {} {} ORDER BY {} LIMIT {},{} {};'.format(select, where, group, order, start, limit, close)
|
||||||
|
#app.logger.debug(sql)
|
||||||
c.execute(sql)
|
c.execute(sql)
|
||||||
for x in c.fetchone().values():
|
queryresults = c.fetchall()
|
||||||
return x
|
|
||||||
|
select = 'COUNT(*)'
|
||||||
|
if listing:
|
||||||
|
if listing == 'races':
|
||||||
|
select = 'COUNT(*) FROM ( SELECT COUNT(event)'
|
||||||
|
close = ') races'
|
||||||
|
elif listing == 'runners':
|
||||||
|
select = 'COUNT(*) FROM ( SELECT COUNT(name)'
|
||||||
|
group = 'GROUP BY CONCAT_WS(" ", name, surname)'
|
||||||
|
close = ') runners'
|
||||||
|
elif listing == 'rankings':
|
||||||
|
select = 'COUNT(*) FROM ( SELECT COUNT(name)'
|
||||||
|
group = 'GROUP BY CONCAT_WS(" ", name, surname)'
|
||||||
|
close = ') rankings'
|
||||||
|
elif listing == 'licence':
|
||||||
|
pass
|
||||||
|
|
||||||
|
sql = 'SELECT {} FROM `results` {} {} {};'.format(select, where, group, close)
|
||||||
|
#app.logger.debug(sql)
|
||||||
|
c.execute(sql)
|
||||||
|
countresult = c.fetchone()
|
||||||
|
for x in countresult.keys():
|
||||||
|
count = countresult[x]
|
||||||
|
app.logger.debug(count)
|
||||||
|
|
||||||
|
return { 'count': int(count), 'rows': queryresults }
|
||||||
|
|
||||||
|
|
||||||
@app.template_filter('pace')
|
@app.template_filter('pace')
|
||||||
def pace(time):
|
def pace(time):
|
||||||
return (dt.datetime(1,1,1) + time).strftime('%M:%S')
|
return (dt.datetime(1,1,1) + time).strftime('%M:%S')
|
||||||
|
|
||||||
@app.template_filter('clean_date')
|
@app.template_filter('year')
|
||||||
|
def year(time):
|
||||||
|
return time.strftime('%Y')
|
||||||
|
|
||||||
|
@app.template_filter('cleandate')
|
||||||
def clean_date(time):
|
def clean_date(time):
|
||||||
if time.month == 1 and time.day == 1:
|
if time.month == 1 and time.day == 1:
|
||||||
return time.strftime('%Y')
|
return time.strftime('%Y')
|
||||||
return time.strftime('%Y-%m-%d')
|
return time.strftime('%Y-%m-%d')
|
||||||
|
|
||||||
@app.template_filter('year')
|
|
||||||
def year(time):
|
|
||||||
return time.strftime('%Y')
|
|
||||||
|
|
||||||
@app.template_filter('ordinal')
|
@app.template_filter('ordinal')
|
||||||
def ordinal(n):
|
def ordinal(n):
|
||||||
return "%d%s" % (n,"tsnrhtdd"[(math.floor(n/10)%10!=1)*(n%10<4)*n%10::4])
|
return "%d%s" % (n,"tsnrhtdd"[(math.floor(n/10)%10!=1)*(n%10<4)*n%10::4])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
|
|
||||||
@ -112,9 +176,15 @@ if __name__ == '__main__':
|
|||||||
# by race
|
# by race
|
||||||
# - and by gender
|
# - and by gender
|
||||||
|
|
||||||
# default: list of races (sorted by recent)
|
# tabs:
|
||||||
# tabs: list of [races (sorted by recent), people (sorted by total kms for the year), licences for the year (sorted by number of races), podiums/winners (people sorted by total_position/total_races), ]
|
# list of races (sorted by recent)
|
||||||
# click to expand by [race (all AAC members by position), person (races by recent), person (races by pace)]
|
# list of people (sorted by total kms for the year)
|
||||||
|
# list of licences for the year (sorted by number of races)
|
||||||
|
# list of podiums/rankings (people sorted by total_position/total_races)
|
||||||
|
# click to expand by
|
||||||
|
# person (races by recent)
|
||||||
|
# person (races by pace)]
|
||||||
|
# race (all AAC members by position)
|
||||||
# SEARCH
|
# SEARCH
|
||||||
|
|
||||||
# /?sort={distance,pace}&sex={m,f}
|
# /?sort={distance,pace}&sex={m,f}
|
||||||
@ -122,6 +192,4 @@ if __name__ == '__main__':
|
|||||||
# /person/Timothy Allen?sort={pace,date}
|
# /person/Timothy Allen?sort={pace,date}
|
||||||
# /person/Timothy Allen/2018
|
# /person/Timothy Allen/2018
|
||||||
# /license/2018/4356
|
# /license/2018/4356
|
||||||
# /license/2018/4356/2018
|
# /license/2018/4356
|
||||||
#
|
|
||||||
# TODO LIMIT/pagination
|
|
||||||
|
BIN
static/AAC_224x224.png
Normal file
BIN
static/AAC_224x224.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 77 KiB |
BIN
static/AAC_224x95.png
Normal file
BIN
static/AAC_224x95.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
@ -1,9 +1,16 @@
|
|||||||
body {
|
body {
|
||||||
margin: 0 auto;
|
margin: 0 auto 15px;
|
||||||
|
padding: 0 8px;
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
font-family: 'Roboto Condensed', sans-serif;
|
font-family: 'Roboto Condensed', sans-serif;
|
||||||
font-size: 11pt;
|
font-size: 11pt;
|
||||||
}
|
}
|
||||||
|
a {
|
||||||
|
color: #154996;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
table {
|
table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -22,11 +29,45 @@ table tr td:last-child {
|
|||||||
table tr td.nowrap {
|
table tr td.nowrap {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
nav.nextprev {
|
nav {
|
||||||
|
display: flex;
|
||||||
|
background-color: #154996;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
}
|
||||||
|
nav span {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
|
nav span {
|
||||||
|
}
|
||||||
|
nav span a {
|
||||||
|
display: block;
|
||||||
|
color: #FFF;
|
||||||
|
}
|
||||||
|
nav.nextprev {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
|
padding: 0 15px;
|
||||||
}
|
}
|
||||||
nav.nextprev span.prev {
|
nav.nextprev span.first,
|
||||||
}
|
nav.nextprev span.last,
|
||||||
|
nav.nextprev span.prev,
|
||||||
nav.nextprev span.next {
|
nav.nextprev span.next {
|
||||||
|
padding: 0 2px;
|
||||||
|
}
|
||||||
|
nav.nextprev span.plain,
|
||||||
|
nav.nextprev span a {
|
||||||
|
display: block;
|
||||||
|
padding: 10px 5px;
|
||||||
|
}
|
||||||
|
nav.tabs {
|
||||||
|
}
|
||||||
|
nav.tabs span {
|
||||||
|
border-right: 1px solid #FFF;
|
||||||
|
}
|
||||||
|
nav.tabs span:last-child {
|
||||||
|
border-right: none;
|
||||||
|
}
|
||||||
|
nav.tabs span a {
|
||||||
|
padding: 15px 10px;
|
||||||
|
font-size: 11pt;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
15
templates/head.html
Normal file
15
templates/head.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en-ZA">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width">
|
||||||
|
<title>Atlantic Athletic Club</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}" />
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
{%- set ns.limit = limit -%}
|
||||||
|
{%- if ns.limit == 0 or ns.limit == PAGE_SIZE -%}
|
||||||
|
{%- set ns.limit = None -%}
|
||||||
|
{%- endif -%}
|
||||||
|
<body>
|
||||||
|
{% include 'tabs.html' with context %}
|
@ -1,29 +1,13 @@
|
|||||||
<!DOCTYPE html>
|
{% set ns = namespace() -%}
|
||||||
<html lang="en-ZA">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width">
|
|
||||||
<title>AAC Statistics</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}" />
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
{%- set ns = namespace() -%}
|
|
||||||
|
|
||||||
{%- set ns.limit = limit -%}
|
{% include 'head.html' with context %}
|
||||||
{%- if ns.limit == 0 or ns.limit == 10 -%}
|
|
||||||
{%- set ns.limit = None -%}
|
|
||||||
{%- endif -%}
|
|
||||||
|
|
||||||
{%- set ns.year = year -%}
|
|
||||||
{%- if ns.year == 0 -%}
|
|
||||||
{%- set ns.year = None -%}
|
|
||||||
{%- endif -%}
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<nav></nav>
|
|
||||||
<article>
|
<article>
|
||||||
<h1>AAC Statistics {% if title %}: {{ title }}{% endif %}</h1>
|
<h1>AAC Statistics {% if title %}: {{ title }}{% endif %}{% if year %} {{ year }}{% endif %}</h1>
|
||||||
{%- if results -%}
|
{% if results -%}
|
||||||
|
{%- set ns.total = 0 -%}
|
||||||
|
{%- if 'count' in results -%}
|
||||||
|
{%- set ns.total = results['count'] -%}
|
||||||
|
{%- endif -%}
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -42,7 +26,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{%- for row in results -%}
|
{%- for row in results['rows'] -%}
|
||||||
{%- set person='{} {}'.format(row.name, row.surname) -%}
|
{%- set person='{} {}'.format(row.name, row.surname) -%}
|
||||||
{%- if distance %}{# set total_km += row.distance #}{% endif -%}
|
{%- if distance %}{# set total_km += row.distance #}{% endif -%}
|
||||||
<tr>
|
<tr>
|
||||||
@ -56,67 +40,20 @@
|
|||||||
{%- if ltype != 'event' -%}
|
{%- if ltype != 'event' -%}
|
||||||
<td><a href="{{ url_for('race', title=row.event, year=row.date|year, start=None, limit=ns.limit) }}">{{ row.event }} ({{ row.distance }} KM)</a></td>
|
<td><a href="{{ url_for('race', title=row.event, year=row.date|year, start=None, limit=ns.limit) }}">{{ row.event }} ({{ row.distance }} KM)</a></td>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
<td>{{ row.date | clean_date }}</td>
|
<td>{{ row.date | cleandate }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if row.sex and row.sexposition and row.sexposition <= 100 %}{{ row.sexposition | ordinal }} {{ row.sex.lower() }}{% endif %}
|
{%- if row.sex and row.sexposition and row.sexposition <= 100 %}{{ row.sexposition | ordinal }} {{ row.sex.lower() }}{% endif -%}
|
||||||
{% if row.sexposition and row.catposition %}/{% endif %}
|
{%- if row.sexposition and row.catposition %}/{% endif -%}
|
||||||
{% if row.catposition and row.catposition <= 100 %}{{ row.catposition | ordinal }} in category{% endif %}
|
{%- if row.catposition and row.catposition <= 100 %}{{ row.catposition | ordinal }} in category{% endif -%}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{%- endif -%}
|
|
||||||
<nav class="nextprev">
|
|
||||||
{%- set ns.start = start -%}
|
|
||||||
{%- set ns.prev = start-limit -%}
|
|
||||||
{%- set ns.next = start+limit -%}
|
|
||||||
{%- if ns.prev == 0-%}
|
|
||||||
{%- set ns.prev = None -%}
|
|
||||||
{%- endif -%}
|
|
||||||
{%- if ns.next == 0-%}
|
|
||||||
{%- set ns.next = None -%}
|
|
||||||
{%- endif -%}
|
|
||||||
{%- if ns.start == 0-%}
|
|
||||||
{%- set ns.start = None -%}
|
|
||||||
{%- endif -%}
|
|
||||||
|
|
||||||
{%- set thispage = (start / limit)|round(0,'floor')|int + 1 -%}
|
|
||||||
{%- set totalpages = (total / limit)|round(0,'ceil')|int -%}
|
|
||||||
{%- set ns.ellipsis = False -%}
|
|
||||||
|
|
||||||
{% if thispage > 1 %}
|
|
||||||
<span class="first"><a href="{{ url_for(request.endpoint, title=title, year=ns.year, start=None, limit=ns.limit) }}">«First</a></span>
|
|
||||||
{% if (start-limit) > 1 %}
|
|
||||||
<span class="prev"><a href="{{ url_for(request.endpoint, title=title, year=ns.year, start=ns.prev, limit=ns.limit) }}"><Prev</a></span>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<span class="navlink">
|
|
||||||
{% for page in range(1, totalpages+1) %}
|
|
||||||
{% if page < 4 or page > (totalpages+1-4) or (page > (thispage-3) and page < (thispage+3)) %}
|
|
||||||
{%- if page != thispage -%}
|
|
||||||
<a href="{{ url_for(request.endpoint, title=title, year=ns.year, start=(page-1)*limit, limit=ns.limit) }}">{{ page }}</a>
|
|
||||||
{%- else -%}
|
|
||||||
<strong>{{ page }}</strong>
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- set ns.ellipsis = False -%}
|
|
||||||
{%- else -%}
|
|
||||||
{%- if not ns.ellipsis -%}
|
|
||||||
…
|
|
||||||
{%- endif -%}
|
|
||||||
{%- set ns.ellipsis = True -%}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
{% if thispage < totalpages %}
|
|
||||||
{% if (start+limit) != (totalpages-1)*limit %}
|
|
||||||
<span class="next"><a href="{{ url_for(request.endpoint, title=title, year=ns.year, start=ns.next, limit=ns.limit) }}">Next></a></span>
|
|
||||||
{% endif %}
|
|
||||||
<span class="last"><a href="{{ url_for(request.endpoint, title=title, year=ns.year, start=(totalpages-1)*limit, limit=ns.limit) }}">Last»</a></span>
|
|
||||||
{% endif %}
|
|
||||||
</nav>
|
|
||||||
</article>
|
</article>
|
||||||
|
<footer>
|
||||||
|
{% include 'prevnext.html' with context %}
|
||||||
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
34
templates/list-licence.html
Normal file
34
templates/list-licence.html
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{% set ns = namespace() -%}
|
||||||
|
|
||||||
|
{% include 'head.html' with context %}
|
||||||
|
<article>
|
||||||
|
<h1>AAC Statistics: {% if year %} {{ year }}{% endif %}{% if title %} {{ title | title }}{% endif %}</h1>
|
||||||
|
{% if results -%}
|
||||||
|
{%- set ns.total = 0 -%}
|
||||||
|
{%- if 'count' in results -%}
|
||||||
|
{%- set ns.total = results['count'] -%}
|
||||||
|
{%- endif -%}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Licence</th>
|
||||||
|
<th>Name</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{%- for row in results['rows'] -%}
|
||||||
|
<tr>
|
||||||
|
<td><a href="{{ url_for('licence', title=row.licence, year=row.date|year, start=None, limit=ns.limit) }}">{{ row.licence }}</td>
|
||||||
|
<td><a href="{{ url_for('person', title=row.person, year=year, start=None, limit=ns.limit) }}">{{ row.person }}</a></td>
|
||||||
|
<td>{{ row.date | year }}</a></td>
|
||||||
|
</tr>
|
||||||
|
{%- endfor -%}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{%- endif %}
|
||||||
|
</article>
|
||||||
|
<footer>
|
||||||
|
{% include 'prevnext.html' with context %}
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
33
templates/list-licences.html
Normal file
33
templates/list-licences.html
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{% set ns = namespace() -%}
|
||||||
|
|
||||||
|
{% include 'head.html' with context %}
|
||||||
|
<article>
|
||||||
|
<h1>AAC Statistics: {% if year %} {{ year }}{% endif %}{% if title %} {{ title | title }}{% endif %}</h1>
|
||||||
|
{% if results -%}
|
||||||
|
{%- set ns.total = 0 -%}
|
||||||
|
{%- if 'count' in results -%}
|
||||||
|
{%- set ns.total = results['count'] -%}
|
||||||
|
{%- endif -%}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Licence</th>
|
||||||
|
<th>Name</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{%- for row in results['rows'] -%}
|
||||||
|
<tr>
|
||||||
|
<td><a href="{{ url_for('licence', title=row.licence, year=year, start=None, limit=ns.limit) }}">{{ row.licence }}</td>
|
||||||
|
<td><a href="{{ url_for('person', title=row.person, year=year, start=None, limit=ns.limit) }}">{{ row.person }}</a></td>
|
||||||
|
</tr>
|
||||||
|
{%- endfor -%}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{%- endif %}
|
||||||
|
</article>
|
||||||
|
<footer>
|
||||||
|
{% include 'prevnext.html' with context %}
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
33
templates/list-races.html
Normal file
33
templates/list-races.html
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{% set ns = namespace() -%}
|
||||||
|
|
||||||
|
{% include 'head.html' with context %}
|
||||||
|
<article>
|
||||||
|
<h1>AAC Statistics: {% if year %} {{ year }}{% endif %}{% if title %} {{ title | title }}{% endif %}</h1>
|
||||||
|
{% if results -%}
|
||||||
|
{%- set ns.total = 0 -%}
|
||||||
|
{%- if 'count' in results -%}
|
||||||
|
{%- set ns.total = results['count'] -%}
|
||||||
|
{%- endif -%}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Event</th>
|
||||||
|
<th>Date</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{%- for row in results['rows'] -%}
|
||||||
|
<tr>
|
||||||
|
<td><a href="{{ url_for('race', title=row.event, year=row.date|year, start=None, limit=ns.limit) }}">{{ row.event }}</a></td>
|
||||||
|
<td>{{ row.date | cleandate }}</td>
|
||||||
|
</tr>
|
||||||
|
{%- endfor -%}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{%- endif %}
|
||||||
|
</article>
|
||||||
|
<footer>
|
||||||
|
{% include 'prevnext.html' with context %}
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
37
templates/list-rankings.html
Normal file
37
templates/list-rankings.html
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{% set ns = namespace() -%}
|
||||||
|
|
||||||
|
{% include 'head.html' with context %}
|
||||||
|
<article>
|
||||||
|
<h1>AAC Statistics: {% if year %} {{ year }}{% endif %}{% if title %} {{ title | title }}{% endif %}</h1>
|
||||||
|
{% if results -%}
|
||||||
|
{%- set ns.total = 0 -%}
|
||||||
|
{%- if 'count' in results -%}
|
||||||
|
{%- set ns.total = results['count'] -%}
|
||||||
|
{%- endif -%}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Average position</th>
|
||||||
|
<th>Sum of race positions</th>
|
||||||
|
<th>Number of races</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{%- for row in results['rows'] -%}
|
||||||
|
<tr>
|
||||||
|
<td><a href="{{ url_for('person', title=row.person, year=year, start=None, limit=ns.limit) }}">{{ row.person }}</a></td>
|
||||||
|
<td>{{ row.score }}</td>
|
||||||
|
<td>{{ row.positions }}</td>
|
||||||
|
<td>{{ row.races }}</td>
|
||||||
|
</tr>
|
||||||
|
{%- endfor -%}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{%- endif %}
|
||||||
|
</article>
|
||||||
|
<footer>
|
||||||
|
{% include 'prevnext.html' with context %}
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
33
templates/list-runners.html
Normal file
33
templates/list-runners.html
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{% set ns = namespace() -%}
|
||||||
|
|
||||||
|
{% include 'head.html' with context %}
|
||||||
|
<article>
|
||||||
|
<h1>AAC Statistics: {% if year %} {{ year }}{% endif %} Top Runners by Race Mileage</h1>
|
||||||
|
{% if results -%}
|
||||||
|
{%- set ns.total = 0 -%}
|
||||||
|
{%- if 'count' in results -%}
|
||||||
|
{%- set ns.total = results['count'] -%}
|
||||||
|
{%- endif -%}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Distance</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{%- for row in results['rows'] -%}
|
||||||
|
<tr>
|
||||||
|
<td><a href="{{ url_for('person', title=row.person, year=year, start=None, limit=ns.limit) }}">{{ row.person }}</a></td>
|
||||||
|
<td>{{ row.total }}</td>
|
||||||
|
</tr>
|
||||||
|
{%- endfor -%}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{%- endif %}
|
||||||
|
</article>
|
||||||
|
<footer>
|
||||||
|
{% include 'prevnext.html' with context %}
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
55
templates/prevnext.html
Normal file
55
templates/prevnext.html
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<nav class="nextprev">
|
||||||
|
{%- set ns.limit = limit -%}
|
||||||
|
{%- if ns.limit == 0 or ns.limit == 10 -%}
|
||||||
|
{%- set ns.limit = None -%}
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
|
{%- set ns.prev = start-limit -%}
|
||||||
|
{%- if ns.prev == 0-%}
|
||||||
|
{%- set ns.prev = None -%}
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
|
{%- set ns.next = start+limit -%}
|
||||||
|
{%- if ns.next == 0-%}
|
||||||
|
{%- set ns.next = None -%}
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
|
{%- set ns.start = start -%}
|
||||||
|
{%- if ns.start == 0-%}
|
||||||
|
{%- set ns.start = None -%}
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
|
{%- set thispage = (start / limit)|round(0,'floor')|int + 1 -%}
|
||||||
|
{%- set totalpages = (ns.total / limit)|round(0,'ceil')|int -%}
|
||||||
|
{%- set ns.ellipsis = False -%}
|
||||||
|
|
||||||
|
{% if thispage > 1 %}
|
||||||
|
<span class="first"><a href="{{ url_for(request.endpoint, title=title, year=year, start=None, limit=ns.limit) }}">« First</a></span>
|
||||||
|
{% if (start-limit) > 1 %}
|
||||||
|
<span class="prev"><a href="{{ url_for(request.endpoint, title=title, year=year, start=ns.prev, limit=ns.limit) }}">< Prev</a></span>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for page in range(1, totalpages+1) %}
|
||||||
|
{% if page < 4 or page > (totalpages+1-4) or (page > (thispage-3) and page < (thispage+3)) %}
|
||||||
|
{%- if page != thispage -%}
|
||||||
|
<span class="nav link"><a href="{{ url_for(request.endpoint, title=title, year=year, start=(page-1)*limit, limit=ns.limit) }}">{{ page }}</a></span>
|
||||||
|
{%- else -%}
|
||||||
|
<span class="nav plain"><strong>{{ page }}</strong></span>
|
||||||
|
{%- endif %}
|
||||||
|
{%- set ns.ellipsis = False -%}
|
||||||
|
{%- else -%}
|
||||||
|
{%- if not ns.ellipsis -%}
|
||||||
|
<span class="nav plain">…</span>
|
||||||
|
{%- endif -%}
|
||||||
|
{%- set ns.ellipsis = True -%}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if thispage < totalpages %}
|
||||||
|
{% if (start+limit) != (totalpages-1)*limit %}
|
||||||
|
<span class="next"><a href="{{ url_for(request.endpoint, title=title, year=year, start=ns.next, limit=ns.limit) }}">Next ></a></span>
|
||||||
|
{% endif %}
|
||||||
|
<span class="last"><a href="{{ url_for(request.endpoint, title=title, year=year, start=(totalpages-1)*limit, limit=ns.limit) }}">Last »</a></span>
|
||||||
|
{% endif %}
|
||||||
|
</nav>
|
7
templates/tabs.html
Normal file
7
templates/tabs.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<nav class="tabs">
|
||||||
|
<span><a href="{{ url_for('list', title='runners', year=now|year, start=None, limit=ns.limit) }}">Runners</a></span>
|
||||||
|
<span><a href="{{ url_for('list', title='rankings', year=now|year, start=None, limit=ns.limit) }}">Rankings</a></span>
|
||||||
|
<span><a href="{{ url_for('list', title='races', year=now|year, start=None, limit=ns.limit) }}">Races</a></span>
|
||||||
|
<span><a href="{{ url_for('list', title='licences', year=now|year, start=None, limit=ns.limit) }}">Licences</a></span>
|
||||||
|
<span><a href="{{ url_for('index', title=None, year=None, start=None, limit=ns.limit) }}">All Results</a></span>
|
||||||
|
</nav>
|
Loading…
Reference in New Issue
Block a user