feat: sitemap hreflang alternates, caching, and lastmod cleanup

Extract sitemap generation to sitemap.py with xhtml:link hreflang
alternates (en/de/x-default) on every URL entry. Add 1-hour in-memory
TTL cache with Cache-Control header. Include supplier pages in both
languages (were EN-only). Drop misleading "today" lastmod from static
pages.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Deeman
2026-02-22 23:13:32 +01:00
parent 76695f3902
commit e270d54f62
4 changed files with 132 additions and 56 deletions

View File

@@ -12,10 +12,12 @@ from unittest.mock import AsyncMock, patch
import aiosqlite
import pytest
from padelnomics import core
from padelnomics.app import create_app
from padelnomics.migrations.migrate import migrate
from padelnomics import core
from padelnomics import sitemap as sitemap_mod
_SCHEMA_CACHE = None
@@ -56,6 +58,9 @@ async def db():
original_db = core._db
core._db = conn
# Clear sitemap cache so tests see fresh DB state
sitemap_mod._cache_xml = ""
sitemap_mod._cache_timestamp = 0.0
yield conn
@@ -147,6 +152,7 @@ def create_subscription(db):
async def scenario(db, test_user):
"""User scenario with valid planner state for PDF generation."""
import json
from padelnomics.planner.calculator import validate_state
state = validate_state({"dblCourts": 4, "sglCourts": 2})
now = datetime.utcnow().isoformat()