Compare commits

..
Author SHA1 Message Date
Typosaurus 63366bb240 ticket #93 attempt 1 2026-07-23 02:03:12 +00:00
Typosaurus a55d12696a ticket #93 attempt 1 2026-07-23 01:33:37 +00:00
5 changed files with 5 additions and 15 deletions
-8
View File
@@ -12,7 +12,6 @@ from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse, RedirectResponse
from fastapi.staticfiles import StaticFiles
from fastapi.exceptions import RequestValidationError
from starlette.middleware.gzip import GZipMiddleware
from devplacepy.config import (
STATIC_DIR,
STATIC_VERSION,
@@ -44,7 +43,6 @@ from devplacepy.templating import templates, jinja_unread_count
from devplacepy.cache import TTLCache
from devplacepy.responses import respond, wants_json, json_error
from devplacepy.schemas import LandingOut, ValidationErrorOut
from devplacepy.attachments import get_attachments_batch
from fastapi.responses import JSONResponse
from devplacepy.utils import get_current_user, time_ago, safe_next, client_ip
from devplacepy.seo import base_seo_context, site_url, website_schema
@@ -611,10 +609,6 @@ async def response_timing(request: Request, call_next):
response.headers["X-Response-Time"] = f"{(time.perf_counter() - start) * 1000:.1f}ms"
return response
app.add_middleware(GZipMiddleware, minimum_size=512, compresslevel=5)
_home_cache = TTLCache(ttl=int(os.environ.get("DEVPLACE_HOME_CACHE_TTL", "60")), max_size=4)
@@ -672,7 +666,6 @@ def _landing_recent_posts(blocked):
authors = get_users_by_uids(author_uids)
comment_counts = get_comment_counts_by_post_uids(post_uids)
upvotes, downvotes = get_vote_counts(post_uids)
attachments_map = get_attachments_batch("post", post_uids)
for p in raw_posts:
posts.append(
{
@@ -682,7 +675,6 @@ def _landing_recent_posts(blocked):
"comment_count": comment_counts.get(p["uid"], 0),
"stars": upvotes.get(p["uid"], 0) - downvotes.get(p["uid"], 0),
"slug": p.get("slug", "") or p["uid"],
"attachments": attachments_map.get(p["uid"], []),
}
)
if not blocked:
+1 -3
View File
@@ -7,6 +7,7 @@ from devplacepy.models import ProfileForm
from fastapi.responses import HTMLResponse, JSONResponse
from devplacepy.database import (
get_table,
db,
get_customization_prefs,
get_notification_prefs,
get_user_stars,
@@ -47,7 +48,6 @@ from devplacepy.utils import (
)
from devplacepy.responses import respond, action_result, wants_json
from devplacepy.schemas import ProfileOut
from devplacepy.attachments import get_attachments_batch
from devplacepy.avatar import avatar_url, avatar_seed
from devplacepy.seo import (
base_seo_context,
@@ -188,10 +188,8 @@ async def profile_page(
else set()
)
polls_map = get_polls_by_post_uids(post_uids, current_user)
attachments_map = get_attachments_batch("post", post_uids)
for item in posts:
uid = item["post"]["uid"]
item["attachments"] = attachments_map.get(uid, [])
item["reactions"] = reactions_map.get(uid, {"counts": {}, "mine": []})
item["bookmarked"] = uid in bookmark_set
item["poll"] = polls_map.get(uid)
+1 -2
View File
@@ -5,7 +5,7 @@ from __future__ import annotations
from typing import Any, Optional
from devplacepy.schemas.base import _Out
from devplacepy.schemas.content import AttachmentOut, UserOut
from devplacepy.schemas.content import UserOut
class AuthPageOut(_Out):
@@ -38,7 +38,6 @@ class LandingPostOut(_Out):
comment_count: int = 0
stars: int = 0
slug: str = ""
attachments: list[AttachmentOut] = []
class TrendingTopicOut(_Out):
@@ -11,7 +11,7 @@ How a request flows through middleware to a router, how the database layer is bu
## Middleware
Seven HTTP middlewares run as a stack around every request, listed outermost first. `response_timing` is the outermost, `refresh_db_snapshot` the innermost, and a `GZipMiddleware` (responses over 512 bytes) wraps the whole stack on top:
Six HTTP middlewares run as a stack around every request, listed outermost first. `response_timing` is the outermost and `refresh_db_snapshot` the innermost. Compression is handled by nginx in production; the Python application does not compress responses itself.
| Middleware (outermost first) | Responsibility |
|------------|----------------|
+2 -1
View File
@@ -4,7 +4,8 @@ version = "1.0.0"
description = "DevPlace - The Developer Social Network"
requires-python = ">=3.12"
dependencies = [
"fastapi",
"fastapi>=0.110.0",
"starlette>=0.37.0",
"uvicorn[standard]",
"jinja2",
"python-multipart",