Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ess using filters for fractions and stuff #369

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 11 additions & 36 deletions freezing/web/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,10 @@ <h3>
<div class="d-flex flex-column gap-3 gap-lg-4">
<div class="card bg-light d-flex flex-row front-page-counts important">
<a class="flex-grow-1 text-center tag-link"
href="/leaderboard/team_text">{{ team_count }}
{% if team_count == 1 %}
team
{% else %}
teams
{% endif %}
href="/leaderboard/team_text">{{ team_count }} team{{ team_count|ess }}
</a>
<a class="flex-grow-1 text-center tag-link"
href="/leaderboard/individual_text">{{ contestant_count }} contestants</a>
href="/leaderboard/individual_text">{{ contestant_count }} contestant{{ contestant_count|ess }}</a>
</div>
<div class="d-grid grid-2 grid-gap-3 grid-gap-lg-4 front-page-counts">
<div class="d-flex align-items-stretch card bg-light stats-card">
Expand All @@ -161,15 +156,15 @@ <h3>
</div>
<div class="d-flex flex-column flex-grow-1 text-nowrap text-center px-3 py-2">
<div>
{{ total_rides|groupnum }} rides
{{ total_rides|groupnum }} ride{{ total_rides|ess }}
</div>
<span class="stat-divider horizontal my-1"></span>
<div>
{{ total_hours|groupnum }} hours
{{ total_hours|groupnum }} hour{{ total_hours|ess }}
</div>
<span class="stat-divider horizontal my-1"></span>
<div>
{{ total_miles|groupnum }} miles
{{ total_miles|groupnum }} mile{{ total_miles|ess }}
</div>
</div>
</div>
Expand All @@ -179,20 +174,15 @@ <h3>
</div>
<div class="d-flex flex-column flex-grow-1 text-nowrap text-center px-3 py-2">
<div>
{{ today_riders }}
{% if today_riders != 1 %}
riders
{% else %}
rider
{% endif %}
{{ today_riders }} rider{{ today_riders|ess }}
</div>
<span class="stat-divider horizontal my-1"></span>
<div>
{{ today_hours|groupnum }} hours
{{ today_hours|groupnum }} hour{{ today_hours|ess }}
</div>
<span class="stat-divider horizontal my-1"></span>
<div>
{{ today_miles|groupnum }} miles
{{ today_miles|groupnum }} mile{{ today_miles|ess }}
</div>
</div>
</div>
Expand All @@ -206,12 +196,7 @@ <h3>
</div>
</div>
<div class="text-center text-muted text-truncate hour-label">
{% if sub_freezing_hours == 1 %}
hour
{% else %}
hours
{% endif %}
below freezing
hour{{ sub_freezing_hours|ess }} below freezing
</div>
</div>
<div class="card bg-light hour-card">
Expand All @@ -222,12 +207,7 @@ <h3>
</div>
</div>
<div class="text-center text-muted text-truncate hour-label">
{% if rain_hours == 1 %}
hour
{% else %}
hours
{% endif %}
in the rain
hour{{ rain_hours|ess }} in the rain
</div>
</div>
<div class="card bg-light hour-card">
Expand All @@ -237,13 +217,8 @@ <h3>
{{ snow_hours|groupnum }}
</div>
</div>
{% if snow_hours == 1 %}
hour
{% else %}
hours
{% endif %}
<div class="text-center text-muted text-truncate hour-label">
in the snow
hour{{ snow_hours|ess }} in the snow
</div>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions freezing/web/views/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def groupnum(number):
return s + ",".join(reversed(groups))


@app.template_filter("ess")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice.

def ess(number):
return "" if groupnum(number) == "1" else "s"


@blueprint.route("/")
def index():
q = text("""select count(*) as num_contestants from lbd_athletes""")
Expand Down
Loading