-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from questionlp/develop
Add new locations and shows reports, migrate from Black to Ruff for linting/formatting
- Loading branch information
Showing
81 changed files
with
694 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Copyright (c) 2018-2025 Linh Pham | ||
# reports.wwdt.me is released under the terms of the Apache License 2.0 | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# vim: set noai syntax=python ts=4 sw=4: | ||
"""WWDTM Location Home vs Away Report Functions.""" | ||
|
||
from mysql.connector.connection import MySQLConnection | ||
from mysql.connector.pooling import PooledMySQLConnection | ||
|
||
|
||
def retrieve_location_home_vs_away( | ||
database_connection: MySQLConnection | PooledMySQLConnection, | ||
) -> list[dict[str, int]] | None: | ||
"""Retrieve counts of home versus away shows broken down by year.""" | ||
if not database_connection.is_connected(): | ||
database_connection.reconnect() | ||
|
||
query = """ | ||
SELECT DISTINCT YEAR(showdate) FROM ww_shows | ||
ORDER BY YEAR(showdate) ASC; | ||
""" | ||
cursor = database_connection.cursor(dictionary=False) | ||
cursor.execute(query) | ||
results = cursor.fetchall() | ||
|
||
if not results: | ||
return None | ||
|
||
years = [year[0] for year in results] | ||
|
||
counts = [] | ||
for year in years: | ||
query = """ | ||
SELECT ( | ||
SELECT COUNT(s.showid) | ||
FROM ww_shows s | ||
JOIN ww_showlocationmap lm ON lm.showid = s.showid | ||
JOIN ww_locations l ON l.locationid = lm.locationid | ||
WHERE YEAR(s.showdate) = %s | ||
AND s.bestof = 0 | ||
AND s.repeatshowid IS NULL | ||
AND l.city = 'Chicago' | ||
AND l.state = 'IL' | ||
) AS 'home', ( | ||
SELECT COUNT(s.showid) | ||
FROM ww_shows s | ||
JOIN ww_showlocationmap lm ON lm.showid = s.showid | ||
JOIN ww_locations l ON l.locationid = lm.locationid | ||
WHERE YEAR(s.showdate) = %s | ||
AND s.bestof = 0 | ||
AND s.repeatshowid IS NULL | ||
AND l.city <> 'Chicago' | ||
AND l.state <> 'IL' | ||
) AS 'away'; | ||
""" | ||
cursor = database_connection.cursor(dictionary=True) | ||
cursor.execute( | ||
query, | ||
( | ||
year, | ||
year, | ||
), | ||
) | ||
result = cursor.fetchone() | ||
|
||
if not result: | ||
counts.append({"year": year, "home": None, "away": None}) | ||
else: | ||
counts.append( | ||
{"year": year, "home": result["home"], "away": result["away"]} | ||
) | ||
|
||
return counts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{% extends "base.html" %} | ||
{% set page_title = "Show Locations: Home vs Away" %} | ||
{% block title %}{{ page_title }} | Locations{% endblock %} | ||
|
||
{% block content %} | ||
<nav aria-label="breadcrumb" id="nav-breadcrumb"> | ||
<ol class="breadcrumb"> | ||
<li class="breadcrumb-item"><a href="{{ url_for('locations.index') }}">Locations</a></li> | ||
<li class="breadcrumb-item active" aria-current="page">{{ page_title }}</li> | ||
</ol> | ||
</nav> | ||
|
||
<div id="intro" class="mb-5"> | ||
<h2>{{ page_title }}</h2> | ||
<p> | ||
This report provides a count of shows recorded at home (any venue or studio | ||
located in Chicago, Illinois) and away, broken down by year. | ||
</p> | ||
</div> | ||
|
||
{% if show_counts %} | ||
<div class="row"> | ||
<div class="col-auto"> | ||
<div class="table-responsive"> | ||
<table class="table table-bordered table-hover report"> | ||
<colgroup> | ||
<col class="date year"> | ||
<col class="count"> | ||
<col class="count"> | ||
</colgroup> | ||
<thead> | ||
<tr> | ||
<th scope="col">Year</th> | ||
<th scope="col">Home</th> | ||
<th scope="col">Away</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for count in show_counts %} | ||
<tr> | ||
<td>{{ count["year"] }}</td> | ||
<td>{{ count["home"] }}</td> | ||
<td>{{ count["away"] }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
<tfoot> | ||
<tr> | ||
<th scope="col">Year</th> | ||
<th scope="col">Home</th> | ||
<th scope="col">Away</th> | ||
</tr> | ||
</tfoot> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
{% else %} | ||
<div class="alert alert-info my-5" role="alert"> | ||
<i class="bi bi-info-circle pe-1"></i> Data for <b>{{ page_title }}</b> is currently unavailable. | ||
</div> | ||
{% endif %} | ||
|
||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.