Repository navigation
feat: add Flickypedia second search query to FlickrBot - #90
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Confidence Score: 4/5Safe to merge; the core extraction and deduplication logic is correct and the new Flickypedia path handles missing templates gracefully. The multi-query iteration and Redis deduplication work correctly together. The two issues found are minor: the mutable class-level list default is only dangerous if a future subclass appends rather than reassigns, and the skipped FlickreviewR status check for dual-template files is mostly covered by the category filter already applied by query 1. src/wikibots/flickr.py — the template-dispatch logic in extract_flickr_data and the missing review-status guard for dual-template files; src/wikibots/lib/bot.py — the mutable class-level search_queries default. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[run loop] --> B{redis.exists?}
B -- yes --> A
B -- no --> C[treat_page]
C --> D[extract_flickr_data]
D --> E{Has 'Uploaded with Flickypedia' template?}
E -- yes --> F[_extract_flickr_id_from_flickypedia reads flickrPhotoUrl]
E -- no --> G[_extract_flickr_id_from_flickreviewer checks status == pass/passed reads sourceurl]
F --> H{flickr_url?}
G --> H
H -- nil --> I[return, skip]
H -- url --> J[_parse_flickr_photo_id]
J --> K[get_flickr_photo with rate-limit retry]
K --> L[build & save SDC claims]
subgraph _search_pages
Q1[Query 1: FlickreviewR reviewed files]
Q2[Query 2: Flickypedia uploads]
Q1 --> Yield[yield pages]
Q2 --> Yield
end
Reviews (1): Last reviewed commit: "feat: add Flickypedia second search quer..." | Re-trigger Greptile |
| search_query = "" | ||
| search_queries: list[str] = [] |
There was a problem hiding this comment.
Mutable class-level default list
search_queries: list[str] = [] is a mutable object shared by all BaseBot subclasses. Any future subclass that calls .append() on the inherited attribute (rather than assigning a new list) would mutate the shared default and corrupt the query list for all other subclasses in the same process. FlickrBot avoids this by reassigning with a list literal, but the footgun remains for future implementers.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
|
||
| flickr_url = ( | ||
| self._extract_flickr_id_from_flickypedia() | ||
| if "Uploaded with Flickypedia" in template_names | ||
| else self._extract_flickr_id_from_flickreviewer() | ||
| ) |
There was a problem hiding this comment.
FlickreviewR status check bypassed for dual-template files
The template dispatch is based on wikicode content, not on which search query found the page. A file returned by query 1 (which requires hastemplate:"FlickreviewR" and the reviewed category) that also carries the Uploaded with Flickypedia template will be routed through _extract_flickr_id_from_flickypedia, skipping the review_status check in _extract_flickr_id_from_flickreviewer. Such files would be processed even if the FlickreviewR status is "fail" or "pending". The category filter incategory:"Flickr images reviewed by FlickreviewR 2" provides the primary guard, but the per-template status check was an additional safety layer for these edge cases.
Add a second search query for files uploaded via Flickypedia.
BaseBotgains asearch_querieslist attribute;FlickrBotuses it to run both queries in sequence. Extraction auto-detects the template:Uploaded with FlickypediausesflickrPhotoUrldirectly; otherwise falls back to the existing FlickreviewR path.