Topic on Talk:Main Page

Avoid usage of RandomSelection

Summary by Robkelk

Technical discussion between Miraheze sysops and All The Tropes administrators, not updated in four years. The technical issues in question have been resolved.

Southparkfan (talkcontribs)

DocColress, Robkelk, Looney Toons, Vorticity, GethN7, whoever that would read this: I see you use RandomSelection on this page. RandomSelection prevents this page from being cached at all, and if I didn't hack RandomSelection to comment the $parser->disableCache(); cache line, it would take ages to load the main page (and send a lot of traffic to the backend layer that could have been served by our cache layer, thus lowering the MediaWiki server load).

I know it might be preferred to just have a random article, but can you please revise your system? For example, look at this. Anything that allows me to deprecate RandomSelection (server-side hacks are annoying, and my hacks are not going to be merged upstream, never.) works for me.

Thank you,

Labster (talkcontribs)

So the parser cache is set at one day, which means we get a new page every day. If we want to set this up in advance using basic Mediawiki, we could do something like this:

{{:Featured Article/{{#switch: {{#time: d }}
| 1 = Action Girl
| 2 = Studio Ghibli
| 3 = Santa Claus
| 31 = Hanlon's Razor

It's not quite as automatic, or as random, but it would change every day automatically. Or we could switch on {{#time: z }} to set up a whole year at a time. That would allow us to do things like |32 = Groundhog Day|359 = Santa Claus.

Looney Toons (talkcontribs)

You know, I like that, the holiday-themed featured articles. Just as long as we get a fair representative sample of articles appropriate to non-Christian holidays as well.

GethN7 (talkcontribs)

Sounds like a plan to me. I want to retain RandomSelection for other possible purposes I have in mind, but if we can get this implemented ASAP, do it.

Robkelk (talkcontribs)

I was about to say that we already have Category:Holidays to draw upon, but it's almost completely unused. Time to fix that... EDIT: Never mind; Category:Holiday Tropes is much better populated

Labster (talkcontribs)

First draft is at {{ShowFeaturedArticle}}. I actually feel like our featured articles shouldn't be in the template namespace -- they should be in Main as Featured Article/..., or in a separate namespace altogether.

The template is already working, and the random list is prefilled by my Perl 6 script.

GethN7 (talkcontribs)

Nice idea, Labster, and it would be easy to move all of our current Featured Blurbs to another namespace if need be, though I'd like to know your preference as to where more concretely before effecting any changes.

Looney Toons (talkcontribs)

Are there supposed to be so many repeats, or is that just a consequence of how many/few blurbs we've set up? Plus, they seem to cluster by month -- Turns Red appears three times in January, The Beatles (band) three times in February, The "Unicorn In The Garden" Rule three times in March... It's just a bit odd. If it's because we're short of 365.25 blurbs, well, we have a whole page of nominees that we could get to work on picking from.

Labster (talkcontribs)
/* This was completely random, I rolled it on a fair die */

This is the w:Birthday problem in action. But in general, yeah, it's because we have fewer than 365 nominees to pick from. Note that if we do have 365 nominees to pick from, we'll still get duplicates in a month with a random pick (as this is exactly the Birthday problem), but I'd change the code do to @featured.pick(365) to generate that list.

I'm actually thinking a new namespace, I guess. It doesn't really matter, but a different namespace means blurbs aren't searchable unless one goes out of the way to search them, which I construe as a feature. Also Special:AllPages might be more useful than a category? Anyone want to bikeshed the namespace name? "Featured:" "Blurb:" "FeaturedPage:"?

GethN7 (talkcontribs)

I like this idea.

I'd use the last name for the namespace, but you could have the other options be an alias for it.

Labster (talkcontribs)

OK, pushed. "Featured Page:" is the namespace name for now, and "Blurb:" is the shortcut. Since there won't be that many, if any, wikilinks to these, we should be able to able to rename the namespace later if someone comes up with a better idea.

Looney Toons (talkcontribs)

In the mean time, I'll try to vet a few more nominees and get them converted over to blurbs. (And use them to replace some of the dupes in the list, rather than rerandomize after the fact.)

I should write a tool to help automate that process, because after doing a couple by hand it really gets boring...

Labster (talkcontribs)

If someone wants to move the pages to a new namespace (hardcoding Main Page during the process), that would be awesome.

This is the script I used to generate the template:

#!/usr/bin/env perl6
use v6;

my $year = 2016;

my @firstdayofmonth = (1..12).map: { :$year, :month( $_ )).day-of-year };
my %first-days = @firstdayofmonth.BagHash;

my $filename = @*ARGS[0];
my @pages = ($filename and $filename.IO.r) ?? $filename.IO.lines !! ("");

say "loaded {@pages.elems} pages";

say "<noinclude>Add a page to the appropriate number to make it display as our featured page on that day of the year.";
say "<!-- This is the ISO day minus 1, because PHP --></noinclude>";
say '{{:{{#switch: {{#time: z}}';
my @months = <January February March April May June July August September October November December>;

for 0 .. ( :$year :12month :31day).day-of-year - 1) -> $day {
    if %first-days{ $day + 1 } {
        say "| ", @months.shift ;
    say "|$day = {@pages.pick.trim}";
say "}}}}";
say "<noinclude>[[Category:ATT Templates]]</noinclude>";