jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1332203?usp=email )

Change subject: watchlist: Reuse fetched pages
......................................................................

watchlist: Reuse fetched pages

Return the pages materialized by count_watchlist and display that same list in 
default mode.

This avoids a second forced retrieval and keeps the count aligned with the 
displayed pages.

Change-Id: I19f261c17472d4d6dc0d37be7044a3670dbf24f0
---
M scripts/watchlist.py
1 file changed, 5 insertions(+), 5 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/scripts/watchlist.py b/scripts/watchlist.py
index 2b8394b..c107abb 100755
--- a/scripts/watchlist.py
+++ b/scripts/watchlist.py
@@ -60,12 +60,13 @@
     return [p.title() for p in site.watched_pages()]


-def count_watchlist(site=None) -> None:
+def count_watchlist(site=None) -> list[pywikibot.Page]:
     """Count only the total number of page(s) in watchlist for this wiki."""
     if site is None:
         site = pywikibot.Site()
-    watchlist_count = len(refresh(site))
-    pywikibot.info(f'There are {watchlist_count} page(s) in the watchlist.')
+    watchlist = refresh(site)
+    pywikibot.info(f'There are {len(watchlist)} page(s) in the watchlist.')
+    return watchlist


 def count_watchlist_all(quiet=False) -> None:
@@ -162,8 +163,7 @@
         count_watchlist_all()
     else:
         site = pywikibot.Site()
-        count_watchlist(site)
-        watchlist = list(site.watched_pages(force=True))
+        watchlist = count_watchlist(site)
         for page in watchlist:
             try:
                 pywikibot.stdout(page.title())

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1332203?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I19f261c17472d4d6dc0d37be7044a3670dbf24f0
Gerrit-Change-Number: 1332203
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to