Skip to content

Ensure autoreview refreshes pending pages and validates new link domains#67

Open
Dhie-boop wants to merge 8 commits into
Wikimedia-Suomi:mainfrom
Dhie-boop:feat/auto-review-check-updated-page
Open

Ensure autoreview refreshes pending pages and validates new link domains#67
Dhie-boop wants to merge 8 commits into
Wikimedia-Suomi:mainfrom
Dhie-boop:feat/auto-review-check-updated-page

Conversation

@Dhie-boop

Copy link
Copy Markdown

Fix #66

that:

  • Uses Pywikibot to fetch the latest revision ID for the page.

  • Returns immediately if the cached revision matches.

  • When it finds a newer revision, calls a new helper (_refresh_page_from_superset) to query Superset for that single page and rebuilds PendingPage / [PendingRevision] (https://github.com/Wikimedia-Suomi/PendingChangesBot-ng/blob/main/app/reviews/models.py) records from the payload.

    • If Superset says the page is no longer pending, deletes the local record and returns None.
  • _refresh_page_from_superset reuses the existing Superset query code path but scopes the results to just the target page, leaving other cached data intact.

  • Updated api_autoreview view to use the helper and 404 when the page isn’t pending anymore.

  • Introduced [WikiClient_fetch_latest_revision_id] (https://github.com/Wikimedia-Suomi/PendingChangesBot-ng/blob/main/app/reviews/services.py ) to encapsulate the Pywikibot call.

  • Strengthened run_autoreview_for_page by adding an external-link domain check backed by a new LRU cache module check_domains The check rejects auto-approvals if new links point to domains the wiki has never used, aligning with “only auto-review familiar external sources” logic.

image image

Comment thread app/reviews/check_domains.py Outdated
raise RuntimeError("Site reference expired; cache needs refresh")

try:
results = site.exturlusage(domain, total=1, namespaces=[0])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in pull request #46 earlier, as we are checking the links after the page is saved the database contain the added link so we need to check if there is least 2 links ( our own link + 1 more )

@zache-fi

Copy link
Copy Markdown
Contributor

also same as 46, the python manage test and ruff check is failing.

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.

Check for if page has been updated before doing automatic review

2 participants