Skip to content

Commit f80cbae

Browse files
feat(seo): enhance SEO functionality and deployment configuration
- increase memory allocation to 1Gi - add timeout parameter for deployment - implement last modified date formatting for SEO
1 parent 34b813d commit f80cbae

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

api/cloudbuild.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
substitutions:
33
_SERVICE_NAME: pyplots-backend
44
_REGION: europe-west4
5-
_MEMORY: 512Mi
5+
_MEMORY: 1Gi
66
_CPU: "1"
77
_MIN_INSTANCES: "1"
88
_MAX_INSTANCES: "3"
@@ -59,6 +59,7 @@ steps:
5959
- "--set-env-vars=GOOGLE_CLOUD_PROJECT=$PROJECT_ID"
6060
- "--set-env-vars=GCS_BUCKET=pyplots-images"
6161
- "--no-cpu-throttling"
62+
- "--timeout=600"
6263
id: "deploy"
6364
waitFor: ["push-image"]
6465

api/routers/seo.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""SEO endpoints (sitemap, bot-optimized pages)."""
22

33
import html
4+
from datetime import datetime
45

56
from fastapi import APIRouter, Depends, HTTPException, Request
67
from fastapi.responses import HTMLResponse, Response
@@ -14,6 +15,11 @@
1415
router = APIRouter(tags=["seo"])
1516

1617

18+
def _lastmod(dt: datetime | None) -> str:
19+
"""Format datetime as <lastmod> XML element, or empty string if None."""
20+
return f"<lastmod>{dt.strftime('%Y-%m-%d')}</lastmod>" if dt else ""
21+
22+
1723
# Minimal HTML template for social media bots (meta tags are what matters)
1824
BOT_HTML_TEMPLATE = """<!DOCTYPE html>
1925
<html lang="en">
@@ -83,11 +89,13 @@ async def get_sitemap(db: AsyncSession | None = Depends(optional_db)):
8389
if spec.impls: # Only include specs with implementations
8490
spec_id = html.escape(spec.id)
8591
# Overview page
86-
xml_lines.append(f" <url><loc>https://pyplots.ai/{spec_id}</loc></url>")
92+
xml_lines.append(f" <url><loc>https://pyplots.ai/{spec_id}</loc>{_lastmod(spec.updated)}</url>")
8793
# Individual implementation pages
8894
for impl in spec.impls:
8995
library_id = html.escape(impl.library_id)
90-
xml_lines.append(f" <url><loc>https://pyplots.ai/{spec_id}/{library_id}</loc></url>")
96+
xml_lines.append(
97+
f" <url><loc>https://pyplots.ai/{spec_id}/{library_id}</loc>{_lastmod(impl.updated)}</url>"
98+
)
9199

92100
xml_lines.append("</urlset>")
93101
xml = "\n".join(xml_lines)

0 commit comments

Comments
 (0)