Skip to content

fix: tolerate purged elements in trending areas query - #100

Open
dadofsambonzuki wants to merge 1 commit into
masterfrom
fix/trending-areas-purged-elements
Open

fix: tolerate purged elements in trending areas query#100
dadofsambonzuki wants to merge 1 commit into
masterfrom
fix/trending-areas-purged-elements

Conversation

@dadofsambonzuki

Copy link
Copy Markdown
Member

Problem

get_trending_countries and get_trending_communities fail with Query returned no rows for any period that contains events whose element was later purged (hard-deleted) from the element table.

In get_trending_areas, each event/comment triggers a select_by_id on the element table; one missing row aborts the entire request. This made the July 2026 monthly stats unqueryable: any range touching July 9, 18, or 31 failed — including the full month and both half-month splits (the previously documented workaround).

Example (full July 2026):

RPC Error: {'code': -32000, 'message': 'Server error', 'data': 'Query returned no rows'}

Fix

Skip events and comments whose element no longer exists instead of erroring the whole query. Only rusqlite::Error::QueryReturnedNoRows is swallowed; genuine database errors still propagate.

Verification

  • cargo fmt --check clean
  • cargo clippy -- -D warnings clean
  • cargo test — 628 passed, 0 failed

Note (out of scope)

The same unguarded select_by_id(...)? pattern exists in rest/v4/activity.rs, where a purged element would similarly 500 the activity feed. Happy to follow up with a separate PR for that if desired.

get_trending_countries and get_trending_communities failed with
"Query returned no rows" for any period containing events whose
element was later purged from the database. The element lookup error
aborted the entire request.

Skip events and comments referencing missing elements instead, so a
single purged element can no longer poison a whole period report.
@dadofsambonzuki
dadofsambonzuki requested a review from bubelov August 4, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant