feat: add author-username search to feed/gists/projects listings and partial-index migration
DevPlace CI / test (push) Failing after 2m5s
DevPlace CI / test (push) Failing after 2m5s
Extend `database.text_search_clause` with an `author_field` parameter that resolves username matches to user UIDs, enabling author-username search across the three public listings (`/feed`, `/gists`, `/projects`). Update the corresponding API docs and README route descriptions to reflect the new search scope. Add six partial indexes (`idx_comments_target_live`, `idx_votes_target_live`, `idx_reactions_target_live`, `idx_gists_live_created`, `idx_projects_live_created`, `idx_attachments_user_created_live`) to optimize filtered queries on non-deleted rows. Introduce a hot-settings cache (`_hot_settings`) with a 2-second TTL for `maintenance_mode`, `rate_limit_per_minute`, and `rate_limit_window_seconds`, plus a periodic rate-limit store sweep (`_sweep_rate_limit_store`) to evict stale IP entries every 60 seconds. Add `GZipMiddleware` to the FastAPI app for response compression.
This commit is contained in:
@@ -33,7 +33,9 @@ def get_feed_posts(
|
||||
):
|
||||
posts_table = get_table("posts")
|
||||
order = ["-stars", "-created_at"] if tab == "trending" else ["-created_at"]
|
||||
search_match = text_search_clause(posts_table, search, ("title", "content"))
|
||||
search_match = text_search_clause(
|
||||
posts_table, search, ("title", "content"), author_field="user_uid"
|
||||
)
|
||||
search_clauses = [search_match] if search_match is not None else []
|
||||
|
||||
if tab == "following":
|
||||
|
||||
@@ -77,7 +77,9 @@ def get_gists_list(user_uid=None, language=None, search="", before=None, viewer=
|
||||
if language:
|
||||
filters["language"] = language
|
||||
|
||||
search_match = text_search_clause(gists_table, search, ("title", "description"))
|
||||
search_match = text_search_clause(
|
||||
gists_table, search, ("title", "description"), author_field="user_uid"
|
||||
)
|
||||
clauses = [search_match] if search_match is not None else []
|
||||
|
||||
total = gists_table.count(*clauses, deleted_at=None, **filters)
|
||||
|
||||
@@ -79,7 +79,9 @@ def get_projects_list(
|
||||
if projects.exists:
|
||||
columns = projects.table.columns
|
||||
clauses.append(columns.deleted_at.is_(None))
|
||||
search_match = text_search_clause(projects, search, ("title", "description"))
|
||||
search_match = text_search_clause(
|
||||
projects, search, ("title", "description"), author_field="user_uid"
|
||||
)
|
||||
if search_match is not None:
|
||||
clauses.append(search_match)
|
||||
if "is_private" in columns:
|
||||
|
||||
Reference in New Issue
Block a user