feat: initial dashboard implementation and robust attendance parsing
- Added a Makefile to easily run project scripts (fees, match, web, image) - Modified attendance.py to dynamically handle a variable number of header rows from the Google Sheet - Updated both attendance calculations and calculate_fees terminal output to show actual attendance counts (e.g., '750 CZK (3)') - Created a Flask web dashboard (app.py and templates/fees.html) to view member fees in an attractive, condensed, terminal-like UI - Bound the Flask server to port 5000 and added a routing alias from '/' to '/fees' - Configured Python virtual environment (.venv) creation directly into the Makefile to resolve global pip install errors on macOS Co-authored-by: Antigravity <antigravity@deepmind.com>
This commit is contained in:
53
scripts/calculate_fees.py
Normal file
53
scripts/calculate_fees.py
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Calculate monthly fees from the FUJ Tuesday practice attendance sheet."""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from attendance import get_members_with_fees
|
||||
|
||||
|
||||
def main():
|
||||
members, sorted_months = get_members_with_fees()
|
||||
if not members:
|
||||
print("No data.")
|
||||
return
|
||||
|
||||
# Filter to adults only for display
|
||||
results = [(name, fees) for name, tier, fees in members if tier == "A"]
|
||||
|
||||
# Format month labels
|
||||
month_labels = {
|
||||
m: datetime.strptime(m, "%Y-%m").strftime("%b %Y") for m in sorted_months
|
||||
}
|
||||
|
||||
# Print table
|
||||
name_width = max((len(r[0]) for r in results), default=20)
|
||||
col_width = 15
|
||||
|
||||
header = f"{'Member':<{name_width}}"
|
||||
for m in sorted_months:
|
||||
header += f" | {month_labels[m]:>{col_width}}"
|
||||
print(header)
|
||||
print("-" * len(header))
|
||||
|
||||
monthly_totals = {m: 0 for m in sorted_months}
|
||||
for name, month_fees in results:
|
||||
line = f"{name:<{name_width}}"
|
||||
for m in sorted_months:
|
||||
fee, count = month_fees[m]
|
||||
monthly_totals[m] += fee
|
||||
cell = f"{fee} CZK ({count})" if count > 0 else "-"
|
||||
line += f" | {cell:>{col_width}}"
|
||||
print(line)
|
||||
|
||||
# Totals row
|
||||
print("-" * len(header))
|
||||
totals_line = f"{'TOTAL':<{name_width}}"
|
||||
for m in sorted_months:
|
||||
cell = f"{monthly_totals[m]} CZK"
|
||||
totals_line += f" | {cell:>{col_width}}"
|
||||
print(totals_line)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user