Module talk:Random portal component
![]() | Portals ![]() | |||||||||
|
Script errors
@Mr. Stradivarius: The recent changes to this module cause every portal that is missing a page to show up in Category:Pages with script errors. What should we do about this? Jackmcbarn (talk) 23:07, 4 December 2014 (UTC)
- @Jackmcbarn: It looks like catching the error and putting them in a separate tracking category would be best. — Mr. Stradivarius ♪ talk ♪ 23:21, 4 December 2014 (UTC)
- I've changed the module to catch errors in portals with non-existent content subpages and put them in Category:Portals needing attention. — Mr. Stradivarius ♪ talk ♪ 23:39, 4 December 2014 (UTC)
Subpage tracking algorithm
@BrownHairedGirl: Thank you for your recent addition of the subpage tracking code. :) I noticed that in Template:Portals with subpages count tracking category you have commented out categories for subpage counts of 51–100, 101–200, 201–500, 501–1000, and >1000, presumably because checking for them would exceed the expensive function count. How about using the shortcut of only checking the boundary pages exist, instead of checking that every page exists? The algorithm would go something like this:
- Check whether subpage #2 exists. If it exists, then move to step 2. If it doesn't, put the page in the category Category:Random portal component with less than 2 available subpages and exit.
- Check whether subpage #6 exists. If it exists, then move to step 3. If it doesn't, put the page in the category Category:Random portal component with 2–5 available subpages and exit.
- Repeat with page #11, #16, #21, #26, #31, #41, #51, #101, #201, and #501.
- Finally, check whether subpage #1001 exists. If it exists, then put the page in Category:Random portal component with more than 1000 available subpages. If it doesn't, put the page in the category Category:Random portal component with 501–1000 available available subpages.
This way you use at most 13 expensive function calls - one for each category. However, there is the drawback that the algorithm won't work properly if there are gaps in the subpage numbers. For example, if a portal has subpages #1, #3 and #4, but #2 doesn't exist, then the algorithm will put it in the "less than 2" category, when it should be in the "2–5" category. Let me know if you think this would be an acceptable trade-off or not. Best — Mr. Stradivarius ♪ talk ♪ 06:17, 2 May 2019 (UTC)