fix: tolerate purged elements in trending areas query - #100
Open
dadofsambonzuki wants to merge 1 commit into
Open
fix: tolerate purged elements in trending areas query#100dadofsambonzuki wants to merge 1 commit into
dadofsambonzuki wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
get_trending_countriesandget_trending_communitiesfail withQuery returned no rowsfor any period that contains events whose element was later purged (hard-deleted) from theelementtable.In
get_trending_areas, each event/comment triggers aselect_by_idon 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):
Fix
Skip events and comments whose element no longer exists instead of erroring the whole query. Only
rusqlite::Error::QueryReturnedNoRowsis swallowed; genuine database errors still propagate.Verification
cargo fmt --checkcleancargo clippy -- -D warningscleancargo test— 628 passed, 0 failedNote (out of scope)
The same unguarded
select_by_id(...)?pattern exists inrest/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.