Restructure; update CSS; centralise start/limit calculations
This commit is contained in:
parent
89f8b5d3b3
commit
711151b828
166
aacstats.py
166
aacstats.py
@ -4,24 +4,70 @@ import math
|
||||
import MySQLdb
|
||||
import MySQLdb.cursors
|
||||
import re
|
||||
import urllib.parse
|
||||
app = Flask(__name__)
|
||||
|
||||
PAGE_SIZE=20
|
||||
MIN_MONTHS_FOR_LISTINGS=3
|
||||
|
||||
def now():
|
||||
return dt.datetime.now()
|
||||
|
||||
def read_db(start=0, limit=PAGE_SIZE, listing=None, event=None, person=None, licence=None, search=dict(), year=None):
|
||||
def getstart():
|
||||
start = request.args.get('start', '0')
|
||||
if not isinstance(start, (int, float)):
|
||||
return 0
|
||||
return start
|
||||
|
||||
def getshow():
|
||||
show = request.args.get('show', PAGE_SIZE)
|
||||
if show == 'all':
|
||||
return -1
|
||||
if not isinstance(show, (int, float)):
|
||||
return PAGE_SIZE
|
||||
return show
|
||||
|
||||
@app.template_filter('urlescape')
|
||||
def urlescape(string):
|
||||
return urllib.parse.quote_plus(string)
|
||||
|
||||
@app.template_filter('pace')
|
||||
def pace(time):
|
||||
return (dt.datetime(1,1,1) + time).strftime('%M:%S')
|
||||
|
||||
@app.template_filter('year')
|
||||
def year(time):
|
||||
return time.strftime('%Y')
|
||||
|
||||
@app.template_filter('cleandate')
|
||||
def clean_date(time):
|
||||
if time.month == 1 and time.day == 1:
|
||||
return time.strftime('%Y')
|
||||
return time.strftime('%Y-%m-%d')
|
||||
|
||||
@app.template_filter('ordinal')
|
||||
def ordinal(n):
|
||||
if not isinstance(n, int) or n < 1:
|
||||
return
|
||||
return "%d%s" % (n,"tsnrhtdd"[(math.floor(n/10)%10!=1)*(n%10<4)*n%10::4])
|
||||
|
||||
def read_db(listing=None, event=None, person=None, licence=None, search=dict(), year=None):
|
||||
db = MySQLdb.connect(user='aac', passwd='saOAcCWHg4LaoSSA', db='AAC',
|
||||
use_unicode=True, charset="utf8", cursorclass=MySQLdb.cursors.DictCursor)
|
||||
c = db.cursor()
|
||||
|
||||
count = 0
|
||||
start = getstart()
|
||||
show = getshow()
|
||||
|
||||
select = '*'
|
||||
close = ''
|
||||
where = 'WHERE club LIKE "AAC"'
|
||||
group = ''
|
||||
order = 'date DESC, event, position'
|
||||
close = ''
|
||||
limit = 'LIMIT {},{}'.format(start, show)
|
||||
if show == -1:
|
||||
limit = ''
|
||||
|
||||
if event:
|
||||
if isinstance(event, str):
|
||||
event = db.escape_string(event).decode()
|
||||
@ -76,7 +122,7 @@ def read_db(start=0, limit=PAGE_SIZE, listing=None, event=None, person=None, lic
|
||||
pass
|
||||
|
||||
if listing:
|
||||
if listing == 'races':
|
||||
if listing == 'race':
|
||||
select = 'event, date'
|
||||
group = 'GROUP BY event'
|
||||
elif listing == 'runners':
|
||||
@ -94,16 +140,17 @@ def read_db(start=0, limit=PAGE_SIZE, listing=None, event=None, person=None, lic
|
||||
group = 'GROUP BY licence'
|
||||
order = 'surname, date DESC'
|
||||
|
||||
sql = 'SELECT {} FROM `results` {} {} ORDER BY {} LIMIT {},{} {};'.format(select, where, group, order, start, limit, close)
|
||||
|
||||
sql = 'SELECT {} FROM `results` {} {} ORDER BY {} {} {};'.format(select, where, group, order, limit, close)
|
||||
app.logger.debug(sql)
|
||||
c.execute(sql)
|
||||
queryresults = c.fetchall()
|
||||
|
||||
select = 'COUNT(*)'
|
||||
if listing:
|
||||
if listing == 'races':
|
||||
if listing == 'race':
|
||||
select = 'COUNT(*) FROM ( SELECT COUNT(event)'
|
||||
close = ') races'
|
||||
close = ') race'
|
||||
elif listing == 'runners':
|
||||
select = 'COUNT(*) FROM ( SELECT COUNT(name)'
|
||||
group = 'GROUP BY CONCAT_WS(" ", name, surname)'
|
||||
@ -116,49 +163,27 @@ def read_db(start=0, limit=PAGE_SIZE, listing=None, event=None, person=None, lic
|
||||
pass
|
||||
|
||||
sql = 'SELECT {} FROM `results` {} {} {};'.format(select, where, group, close)
|
||||
#app.logger.debug(sql)
|
||||
app.logger.debug(sql)
|
||||
c.execute(sql)
|
||||
countresult = c.fetchone()
|
||||
for x in countresult.keys():
|
||||
count = countresult[x]
|
||||
#app.logger.debug(count)
|
||||
app.logger.debug(count)
|
||||
|
||||
return { 'count': int(count), 'rows': queryresults }
|
||||
|
||||
def now():
|
||||
return dt.datetime.now()
|
||||
|
||||
|
||||
@app.template_filter('pace')
|
||||
def pace(time):
|
||||
return (dt.datetime(1,1,1) + time).strftime('%M:%S')
|
||||
|
||||
@app.template_filter('year')
|
||||
def year(time):
|
||||
return time.strftime('%Y')
|
||||
|
||||
@app.template_filter('cleandate')
|
||||
def clean_date(time):
|
||||
if time.month == 1 and time.day == 1:
|
||||
return time.strftime('%Y')
|
||||
return time.strftime('%Y-%m-%d')
|
||||
|
||||
@app.template_filter('ordinal')
|
||||
def ordinal(n):
|
||||
if not isinstance(n, int) or n < 1:
|
||||
return
|
||||
return "%d%s" % (n,"tsnrhtdd"[(math.floor(n/10)%10!=1)*(n%10<4)*n%10::4])
|
||||
|
||||
@app.route('/')
|
||||
@app.route('/list')
|
||||
@app.route('/list/<title>') # title = { races, rankings, runners, licence }
|
||||
@app.route('/list/<title>/<int:year>')
|
||||
@app.route('/<title>')
|
||||
@app.route('/<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', ):
|
||||
title = urllib.parse.unquote_plus(title)
|
||||
if title not in ( 'race', 'rankings', 'runners', 'licence', ):
|
||||
abort(404)
|
||||
|
||||
''' In early January, we'll be left with blank pages in listings, since there won't
|
||||
@ -172,61 +197,56 @@ def list(title=None, year=None):
|
||||
lastyear = date - dt.timedelta(days=(MIN_MONTHS_FOR_LISTINGS * 31))
|
||||
year = lastyear.year
|
||||
|
||||
start = int(request.args.get('start', '0'))
|
||||
limit = int(request.args.get('limit', PAGE_SIZE))
|
||||
results = read_db(start, limit, listing=title, year=year)
|
||||
return render_template('list-'+title+'.html', ltype='listing', title=title, year=year,
|
||||
results=results, start=start, limit=limit,
|
||||
request=request, now=now(), PAGE_SIZE=PAGE_SIZE)
|
||||
results = read_db(listing=title, year=year)
|
||||
return render_template('list-'+title+'.html', ltype='listing', title=title,
|
||||
results=results, year=year,
|
||||
request=request, getstart=getstart(), getshow=getshow(), 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)
|
||||
|
||||
if title is not None:
|
||||
title = urllib.parse.unquote_plus(title)
|
||||
results = read_db(year=year)
|
||||
return render_template('index.html', ltype='index',
|
||||
results=results, year=year,
|
||||
request=request, getstart=getstart(), getshow=getshow(), now=now(), PAGE_SIZE=PAGE_SIZE)
|
||||
|
||||
@app.route('/race/<int:year>/<title>')
|
||||
def race(year=None, title=None):
|
||||
start = int(request.args.get('start', '0'))
|
||||
limit = int(request.args.get('limit', PAGE_SIZE))
|
||||
results = read_db(start, limit, event=title, year=year)
|
||||
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)
|
||||
if title is not None:
|
||||
title = urllib.parse.unquote_plus(title)
|
||||
results = read_db(event=title, year=year)
|
||||
return render_template('index.html', ltype='race', title=title,
|
||||
results=results, year=year,
|
||||
request=request, getstart=getstart(), getshow=getshow(), now=now(), PAGE_SIZE=PAGE_SIZE)
|
||||
|
||||
@app.route('/person/<title>')
|
||||
@app.route('/person/<title>/<int:year>')
|
||||
def person(title=None, year=None):
|
||||
start = int(request.args.get('start', '0'))
|
||||
limit = int(request.args.get('limit', PAGE_SIZE))
|
||||
results = read_db(start, limit, person=title, year=year)
|
||||
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)
|
||||
if title is not None:
|
||||
title = urllib.parse.unquote_plus(title)
|
||||
results = read_db(person=title, year=year)
|
||||
return render_template('index.html', ltype='person', title=title,
|
||||
results=results, year=year,
|
||||
request=request, getstart=getstart(), getshow=getshow(), now=now(), PAGE_SIZE=PAGE_SIZE)
|
||||
|
||||
@app.route('/licence/<int:year>')
|
||||
@app.route('/licence/<int:year>/<title>')
|
||||
def licence(year=now().year, title=None):
|
||||
start = int(request.args.get('start', '0'))
|
||||
limit = int(request.args.get('limit', PAGE_SIZE))
|
||||
results = read_db(start, limit, licence=title, year=year)
|
||||
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)
|
||||
if title is not None:
|
||||
title = urllib.parse.unquote_plus(title)
|
||||
results = read_db(licence=title, year=year)
|
||||
return render_template('index.html', ltype='licence', title=title,
|
||||
results=results, year=year,
|
||||
request=request, getstart=getstart(), getshow=getshow(), now=now(), PAGE_SIZE=PAGE_SIZE)
|
||||
|
||||
@app.route('/search')
|
||||
def search():
|
||||
start = int(request.args.get('start', '0'))
|
||||
limit = int(request.args.get('limit', PAGE_SIZE))
|
||||
results = read_db(start, limit, search=request.args)
|
||||
return render_template('search.html', ltype='index', year=None,
|
||||
results=results, start=start, limit=limit,
|
||||
request=request, now=now(), PAGE_SIZE=PAGE_SIZE)
|
||||
results = read_db(search=request.args)
|
||||
return render_template('index.html', ltype='search', title='Search',
|
||||
results=results, year=None,
|
||||
request=request, getstart=getstart(), getshow=getshow(), now=now(), PAGE_SIZE=PAGE_SIZE)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
123
static/style.css
123
static/style.css
@ -5,7 +5,7 @@ body {
|
||||
font-size: 11pt;
|
||||
}
|
||||
a {
|
||||
color: #154996;
|
||||
color: rgba(21, 73, 150, 100%);
|
||||
}
|
||||
h1 {
|
||||
text-align: center;
|
||||
@ -13,27 +13,11 @@ h1 {
|
||||
article {
|
||||
padding: 0 8px;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
table th {
|
||||
text-align: left;
|
||||
font-size: 10pt;
|
||||
}
|
||||
table tr td {
|
||||
padding-right: 10px;
|
||||
border-bottom: 1px solid grey;
|
||||
}
|
||||
table tr td:last-child {
|
||||
padding: 0;
|
||||
}
|
||||
table tr td.nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Navigation elements */
|
||||
nav {
|
||||
display: flex;
|
||||
background-color: #154996;
|
||||
background-color: rgba(21, 73, 150, 100%);
|
||||
text-align: center;
|
||||
}
|
||||
nav span {
|
||||
@ -46,6 +30,20 @@ nav span a {
|
||||
display: block;
|
||||
color: #FFF;
|
||||
}
|
||||
nav.tabs {
|
||||
}
|
||||
nav.tabs span {
|
||||
border-right: 1px solid #FFF;
|
||||
}
|
||||
nav.tabs span:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
nav.tabs span a {
|
||||
padding-top: 15px;
|
||||
padding-bottom: 15px;
|
||||
font-size: 10pt;
|
||||
font-weight: bold;
|
||||
}
|
||||
nav.nextprev {
|
||||
margin-top: 10px;
|
||||
padding: 0 15px;
|
||||
@ -61,19 +59,84 @@ nav.nextprev span a {
|
||||
display: block;
|
||||
padding: 10px 5px;
|
||||
}
|
||||
nav.tabs {
|
||||
|
||||
/* Results lists */
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
nav.tabs span {
|
||||
border-right: 1px solid #FFF;
|
||||
table thead,
|
||||
table tbody {
|
||||
}
|
||||
nav.tabs span:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
nav.tabs span a {
|
||||
padding: 15px 10px;
|
||||
table thead th {
|
||||
text-align: left;
|
||||
font-size: 10pt;
|
||||
font-weight: bold;
|
||||
}
|
||||
table tr {
|
||||
}
|
||||
table tr td {
|
||||
padding-right: 10px;
|
||||
border-bottom: 1px solid grey;
|
||||
}
|
||||
table tr td:last-child {
|
||||
padding-right: 0;
|
||||
}
|
||||
table tr td.nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
table tr td span.label {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media
|
||||
only screen and (max-width: 600px) {
|
||||
/* Force table to not be like tables anymore */
|
||||
table.wide,
|
||||
table.wide thead,
|
||||
table.wide tbody,
|
||||
table.wide thead th,
|
||||
table.wide tr,
|
||||
table.wide tr td {
|
||||
display: block;
|
||||
|
||||
}
|
||||
table.wide thead tr {
|
||||
display: none;
|
||||
}
|
||||
table.wide tr:nth-of-type(even) {
|
||||
border: 1px solid rgba(21, 73, 150, 60%);
|
||||
}
|
||||
table.wide tr:nth-of-type(odd) {
|
||||
background-color: rgba(21, 73, 150, 60%);
|
||||
}
|
||||
table.wide tr:nth-of-type(odd) a {
|
||||
color: #FFF;
|
||||
}
|
||||
table.wide tr td {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
/* Behave like a "row" */
|
||||
border: none;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 10%);
|
||||
}
|
||||
table.wide tr td span {
|
||||
flex: 2;
|
||||
padding-right: 10px;
|
||||
}
|
||||
table.wide tr td span.label {
|
||||
display: initial;
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
}
|
||||
table.wide tr td,
|
||||
table.wide tr td:last-child {
|
||||
padding-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Search box */
|
||||
div.search {
|
||||
margin: 0 10px 15px;
|
||||
display: flex;
|
||||
@ -81,7 +144,7 @@ div.search {
|
||||
align-items: stretch;
|
||||
}
|
||||
div.search > div {
|
||||
flex: 1 1 300px;
|
||||
flex: 1 1 250px;
|
||||
padding: 5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
@ -3,13 +3,21 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>Atlantic Athletic Club</title>
|
||||
<title>Atlantic Athletic Club Results</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 -%}
|
||||
{%- set ns.start = getstart -%}
|
||||
{%- set ns.show = getshow -%}
|
||||
|
||||
{# Reset arguments, so as not to display standard arguments in the query part of the URL #}
|
||||
{%- if ns.start == 0 -%}
|
||||
{%- set ns.start = None -%}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if ns.show == 0 or ns.show == PAGE_SIZE -%}
|
||||
{%- set ns.show = None -%}
|
||||
{%- endif -%}
|
||||
|
||||
<body>
|
||||
{% include 'tabs.html' with context %}
|
||||
|
@ -2,13 +2,17 @@
|
||||
|
||||
{% include 'head.html' with context %}
|
||||
<article>
|
||||
<h1>AAC Statistics {% if title %}: {{ title }}{% endif %}{% if year %} {{ year }}{% endif %}</h1>
|
||||
<h1>AAC Results{% if title %}: {% if ltype == 'licence' %}Licence {% endif %}{{ title }}{% endif %}{% if year %} ({{ year }}){% endif %}</h1>
|
||||
|
||||
{% if ltype == 'search' -%}
|
||||
{% include 'search.html' with context %}
|
||||
{%- endif -%}
|
||||
{% if results -%}
|
||||
{%- set ns.total = 0 -%}
|
||||
{%- if 'count' in results -%}
|
||||
{%- set ns.total = results['count'] -%}
|
||||
{%- endif -%}
|
||||
<table>
|
||||
<table class="wide">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Position</th>
|
||||
@ -19,7 +23,7 @@
|
||||
<th>Time</th>
|
||||
<th>Average Pace</th>
|
||||
{% if ltype != 'event' %}
|
||||
<th>Event</th>
|
||||
<th>Race</th>
|
||||
{% endif %}
|
||||
<th>Date</th>
|
||||
<th>Notes</th>
|
||||
@ -27,24 +31,22 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{%- for row in results['rows'] -%}
|
||||
{%- set person='{} {}'.format(row.name, row.surname) -%}
|
||||
{%- if distance %}{# set total_km += row.distance #}{% endif -%}
|
||||
{%- set person='{} {}'.format(row.name|e, row.surname|e) -%}
|
||||
<tr>
|
||||
<td>{{ row.position }}</td>
|
||||
{%- if ltype != 'person' -%}
|
||||
<td><a href="{{ url_for('person', title=person, start=None) }}">{{ person }}</a></td>
|
||||
<td><a href="{{ url_for('licence', title=row.licence, year=row.date|year, start=None, limit=ns.limit) }}">{{ row.licence }}</a></td>
|
||||
{%- endif -%}
|
||||
<td>{{ row.time }}</td>
|
||||
<td class="nowrap">{% if row.distance is number %}{{ (row.time / row.distance) | pace }} min/KM{% endif %}</td>
|
||||
<td class="nowrap"><span class="label">Position</span> <span>{{ row.position|e }}</span></td>
|
||||
<td class="nowrap"><span class="label">Name</span> <span><a href="{{ url_for('person', title=person|urlescape, start=None) }}">{{ person }}</a></span></td>
|
||||
<td class="nowrap"><span class="label">Licence</span> <span><a href="{{ url_for('licence', title=row.licence|urlescape, year=row.date|year, start=None, show=ns.show) }}">{{ row.licence|e }}</a></span></td>
|
||||
<td><span class="label">Time</span> <span>{{ row.time|e }}</span></td>
|
||||
<td class="nowrap"><span class="label">Average Pace</span> <span>{% if row.distance is number and row.distance|int != 0 %}{{ (row.time / row.distance) | pace }} min/KM{% endif %}</span></td>
|
||||
{%- 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 class="long"><span class="label">Race</span> <span><a href="{{ url_for('race', title=row.event|urlescape, year=row.date|year, start=None, show=ns.show) }}">{{ row.event|e }} ({{ row.distance|e }} KM)</a></span></td>
|
||||
{%- endif -%}
|
||||
<td>{{ row.date | cleandate }}</td>
|
||||
<td>
|
||||
{%- if row.sex and row.sexposition and row.sexposition | int <= 100 %}{{ row.sexposition | ordinal }} {{ row.sex.lower() }}{% endif -%}
|
||||
<td class="nowrap"><span class="label">Date</span> <span>{{ row.date|cleandate|e }}</span></td>
|
||||
<td class="long"><span class="label">Notes</span> <span>
|
||||
{%- if row.sex and row.sexposition and row.sexposition | int <= 100 %}{{ row.sexposition|ordinal|e }} {{ row.sex|lower|e }}{% endif -%}
|
||||
{%- if row.sexposition and row.sexposition | int <= 100 and row.catposition and row.catposition | int <= 100 %} and {% endif -%}
|
||||
{%- if row.catposition and row.catposition | int <= 100 %}{{ row.catposition | ordinal }} in category{% endif -%}
|
||||
{%- if row.catposition and row.catposition | int <= 100 %}{{ row.catposition|ordinal|e }} in category{% endif -%}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
{%- endfor -%}
|
||||
|
@ -2,25 +2,26 @@
|
||||
|
||||
{% include 'head.html' with context %}
|
||||
<article>
|
||||
<h1>AAC Statistics: {% if year %} {{ year }}{% endif %}{% if title %} {{ title | title }}{% endif %}</h1>
|
||||
<h1>AAC Results: Licences{% if year %} for {{ year }}{% endif %}</h1>
|
||||
{% if results -%}
|
||||
{%- set ns.total = 0 -%}
|
||||
{%- if 'count' in results -%}
|
||||
{%- set ns.total = results['count'] -%}
|
||||
{%- endif -%}
|
||||
<table>
|
||||
<table class="narrow">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Licence</th>
|
||||
<th>Name</th>
|
||||
<th>Year</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>
|
||||
<td><span class="label">Licence</span> <span><a href="{{ url_for('licence', title=row.licence|urlescape, year=row.date|year, start=None, show=ns.show) }}">{{ row.licence|e }}</a></span></td>
|
||||
<td><span class="label">Name</span> <span><a href="{{ url_for('person', title=row.person|urlescape, year=year, start=None, show=ns.show) }}">{{ row.person|e }}</a></span></td>
|
||||
<td><span class="label">Year</span> <span>{{ row.date | year }}</a></span></td>
|
||||
</tr>
|
||||
{%- endfor -%}
|
||||
</tbody>
|
||||
|
33
templates/list-race.html
Normal file
33
templates/list-race.html
Normal file
@ -0,0 +1,33 @@
|
||||
{% set ns = namespace() -%}
|
||||
|
||||
{% include 'head.html' with context %}
|
||||
<article>
|
||||
<h1>AAC Results: Races {% if year %} in {{ year }}{% endif %}</h1>
|
||||
{% if results -%}
|
||||
{%- set ns.total = 0 -%}
|
||||
{%- if 'count' in results -%}
|
||||
{%- set ns.total = results['count'] -%}
|
||||
{%- endif -%}
|
||||
<table class="narrow">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Race</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{%- for row in results['rows'] -%}
|
||||
<tr>
|
||||
<td><span class="label">Race</span> <span><a href="{{ url_for('race', title=row.event|urlescape, year=row.date|year, start=None, show=ns.show) }}">{{ row.event|e }}</a></span></td>
|
||||
<td><span class="label">Date</span> <span>{{ row.date | cleandate }}</span></td>
|
||||
</tr>
|
||||
{%- endfor -%}
|
||||
</tbody>
|
||||
</table>
|
||||
{%- endif %}
|
||||
</article>
|
||||
<footer>
|
||||
{% include 'prevnext.html' with context %}
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -2,28 +2,28 @@
|
||||
|
||||
{% include 'head.html' with context %}
|
||||
<article>
|
||||
<h1>AAC Statistics: {% if year %} {{ year }}{% endif %}{% if title %} {{ title | title }}{% endif %}</h1>
|
||||
<h1>AAC Results: Rankings{% if year %} for {{ year }}{% endif %}</h1>
|
||||
{% if results -%}
|
||||
{%- set ns.total = 0 -%}
|
||||
{%- if 'count' in results -%}
|
||||
{%- set ns.total = results['count'] -%}
|
||||
{%- endif -%}
|
||||
<table>
|
||||
<table class="narrow">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Average position</th>
|
||||
<th>Sum of race positions</th>
|
||||
<th>Number of races</th>
|
||||
<th>Average Position</th>
|
||||
<!--th>Sum of Race Positions</th-->
|
||||
<th>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>
|
||||
<td><span class="label">Name</span> <span><a href="{{ url_for('person', title=row.person|urlescape, year=year, start=None, show=ns.show) }}">{{ row.person|e }}</a></span></td>
|
||||
<td><span class="label">Average Position</span> <span>{{ row.score|e }}</span></td>
|
||||
<!--td><span class="label">Sum of Race Positions</span> <span>{{ row.positions|e }}</span></td-->
|
||||
<td><span class="label">Number of Races</span> <span>{{ row.races|e }}</span></td>
|
||||
</tr>
|
||||
{%- endfor -%}
|
||||
</tbody>
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
{% include 'head.html' with context %}
|
||||
<article>
|
||||
<h1>AAC Statistics: {% if year %} {{ year }}{% endif %} Top Runners by Race Mileage</h1>
|
||||
<h1>AAC Results: Top Runners by Race Mileage{% if year %} in {{ year }}{% endif %}</h1>
|
||||
{% if results -%}
|
||||
{%- set ns.total = 0 -%}
|
||||
{%- if 'count' in results -%}
|
||||
{%- set ns.total = results['count'] -%}
|
||||
{%- endif -%}
|
||||
<table>
|
||||
<table class="narrow">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
@ -18,8 +18,8 @@
|
||||
<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>
|
||||
<td><span class="label">Name</span> <span><a href="{{ url_for('person', title=row.person|urlescape, year=year, start=None, show=ns.show) }}">{{ row.person|e }}</a></span></td>
|
||||
<td><span class="label">Distance</span> <span>{{ row.total|e }}</span></td>
|
||||
</tr>
|
||||
{%- endfor -%}
|
||||
</tbody>
|
||||
|
@ -1,39 +1,29 @@
|
||||
<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 -%}
|
||||
{%- set ns.prev = getstart - getshow -%}
|
||||
{%- if ns.prev == 0 -%}
|
||||
{%- set ns.prev = None -%}
|
||||
{%- endif -%}
|
||||
|
||||
{%- set ns.next = start+limit -%}
|
||||
{%- set ns.next = getstart + getshow -%}
|
||||
{%- 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 thispage = (getstart / getshow)|round(0,'floor')|int + 1 -%}
|
||||
{%- set totalpages = (ns.total / getshow)|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>
|
||||
<span class="first"><a href="{{ url_for(request.endpoint, title=title, year=year, start=None, show=show) }}">« First</a></span>
|
||||
{% if (getstart - getshow) > 1 %}
|
||||
<span class="prev"><a href="{{ url_for(request.endpoint, title=title, year=year, start=ns.prev, show=show) }}">‹ 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>
|
||||
<span class="nav link"><a href="{{ url_for(request.endpoint, title=title, year=year, start=(page - 1) * getshow, show=show) }}">{{ page }}</a></span>
|
||||
{%- else -%}
|
||||
<span class="nav plain"><strong>{{ page }}</strong></span>
|
||||
{%- endif %}
|
||||
@ -47,9 +37,9 @@
|
||||
{% 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>
|
||||
{% if (getstart + getshow) != (totalpages - 1) * getshow %}
|
||||
<span class="next"><a href="{{ url_for(request.endpoint, title=title, year=year, start=ns.next, show=show) }}">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>
|
||||
<span class="last"><a href="{{ url_for(request.endpoint, title=title, year=year, start=(totalpages - 1) * getshow, show=show) }}">Last »</a></span>
|
||||
{% endif %}
|
||||
</nav>
|
||||
|
@ -1,8 +1,3 @@
|
||||
{% set ns = namespace() -%}
|
||||
|
||||
{% include 'head.html' with context %}
|
||||
<article>
|
||||
<h1>AAC Statistics {% if title %}: {{ title }}{% endif %}{% if year %} {{ year }}{% endif %}</h1>
|
||||
<form class="search">
|
||||
<div class="search">
|
||||
<div>
|
||||
@ -29,52 +24,6 @@
|
||||
<label for="searchposition">Position</label>
|
||||
<input type="text" id="searchposition" name="position" value="{{ request.args.get('position', '') }}" />
|
||||
</div-->
|
||||
<div><input type="submit" id="searchsubmit" name="submit" /></div>
|
||||
<div><input type="submit" id="searchsubmit" name="submit" value="Search" /></div>
|
||||
</div>
|
||||
</form>
|
||||
{% if results -%}
|
||||
{%- set ns.total = 0 -%}
|
||||
{%- if 'count' in results -%}
|
||||
{%- set ns.total = results['count'] -%}
|
||||
{%- endif -%}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Position</th>
|
||||
<th>Name</th>
|
||||
<th>Licence</th>
|
||||
<th>Time</th>
|
||||
<th>Average Pace</th>
|
||||
<th>Event</th>
|
||||
<th>Date</th>
|
||||
<th>Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{%- for row in results['rows'] -%}
|
||||
{%- set person='{} {}'.format(row.name, row.surname) -%}
|
||||
{%- if distance %}{# set total_km += row.distance #}{% endif -%}
|
||||
<tr>
|
||||
<td>{{ row.position }}</td>
|
||||
<td><a href="{{ url_for('person', title=person, start=None) }}">{{ person }}</a></td>
|
||||
<td><a href="{{ url_for('licence', title=row.licence, year=row.date|year, start=None, limit=ns.limit) }}">{{ row.licence }}</a></td>
|
||||
<td>{{ row.time }}</td>
|
||||
<td class="nowrap">{% if row.distance is number %}{{ (row.time / row.distance) | pace }} min/KM{% endif %}</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>
|
||||
<td>{{ row.date | cleandate }}</td>
|
||||
<td>
|
||||
{%- if row.sex and row.sexposition and row.sexposition | int <= 100 %}{{ row.sexposition | ordinal }} {{ row.sex.lower() }}{% endif -%}
|
||||
{%- if row.sexposition and row.sexposition | int <= 100 and row.catposition and row.catposition | int <= 100 %} and {% endif -%}
|
||||
{%- if row.catposition and row.catposition | int <= 100 %}{{ row.catposition | ordinal }} in category{% endif -%}
|
||||
</td>
|
||||
</tr>
|
||||
{%- endfor -%}
|
||||
</tbody>
|
||||
</table>
|
||||
{%- endif %}
|
||||
</article>
|
||||
<footer>
|
||||
{% include 'prevnext.html' with context %}
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,8 +1,8 @@
|
||||
<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='licence', 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>
|
||||
<span><a href="{{ url_for('search', title=None, year=None, start=None, limit=ns.limit) }}">Search</a></span>
|
||||
<span><a href="{{ url_for('list', title='runners', year=now|year, start=None, show=ns.show) }}">Runners</a></span>
|
||||
<span><a href="{{ url_for('list', title='rankings', year=now|year, start=None, show=ns.show) }}">Rankings</a></span>
|
||||
<span><a href="{{ url_for('list', title='race', year=now|year, start=None, show=ns.show) }}">Races</a></span>
|
||||
<span><a href="{{ url_for('list', title='licence', year=now|year, start=None, show=ns.show) }}">Licences</a></span>
|
||||
<span><a href="{{ url_for('index', title=None, year=None, start=None, show=ns.show) }}">All Results</a></span>
|
||||
<span><a href="{{ url_for('search', title=None, year=None, start=None, show=ns.show) }}">Search</a></span>
|
||||
</nav>
|
||||
|
Loading…
Reference in New Issue
Block a user