Render markdown in gist and project sidebar titles; add content visibility and GIF picker
DevPlace CI / test (push) Failing after 1h5m29s
DevPlace CI / test (push) Failing after 1h5m29s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
from .core import TTLCache, datetime, db, timedelta, timezone
|
||||
from .ranking import get_top_authors
|
||||
from .visibility import listed_clause
|
||||
|
||||
|
||||
_stats_cache = TTLCache(ttl=30, max_size=50)
|
||||
@@ -16,19 +17,20 @@ def get_site_stats() -> dict:
|
||||
.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
.isoformat()
|
||||
)
|
||||
def listed_count(name, **filters):
|
||||
if name not in db.tables:
|
||||
return 0
|
||||
listed = listed_clause(db[name])
|
||||
clauses = [listed] if listed is not None else []
|
||||
return db[name].count(*clauses, **filters)
|
||||
|
||||
stats = {
|
||||
"total_members": db["users"].count() if "users" in db.tables else 0,
|
||||
"posts_today": db["posts"].count(
|
||||
created_at={">=": today_start}, deleted_at=None
|
||||
)
|
||||
if "posts" in db.tables
|
||||
else 0,
|
||||
"total_projects": db["projects"].count(deleted_at=None)
|
||||
if "projects" in db.tables
|
||||
else 0,
|
||||
"total_gists": db["gists"].count(deleted_at=None)
|
||||
if "gists" in db.tables
|
||||
else 0,
|
||||
"posts_today": listed_count(
|
||||
"posts", created_at={">=": today_start}, deleted_at=None
|
||||
),
|
||||
"total_projects": listed_count("projects", deleted_at=None),
|
||||
"total_gists": listed_count("gists", deleted_at=None),
|
||||
}
|
||||
_stats_cache.set("site", stats)
|
||||
return stats
|
||||
|
||||
Reference in New Issue
Block a user