Page MenuHomePhabricator

[Automatic Translation] Random Topic Button is not functional
Closed, ResolvedPublic4 Estimated Story PointsBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

  • Nothing happens

What should have happened instead?:

  • Random topic should have been generated

Other information (browser name/version, screenshots, etc.):
Chrome

Screenshot 2024-05-14 at 1.10.15 PM.png (547×1 px, 37 KB)

From the parent task (T359401):

Random topic action. The "Random topic" action will lead the user to the "Confirm" step (T359512) with a random article pre-selected. If possible, the same algorithm/API used on the wikis. This could be based on the Special:Random where the specific Wikipedia language to request the random page is also randomized. Alternatively we can consider the Random item function from Wikidata (but making sure that a Wikipedia article exists for the selected topic).

Current implementation plan

https://phabricator.wikimedia.org/T364905#10616475

Event Timeline

Pginer-WMF added a project: MinT.
Pginer-WMF added a parent task: T359401: MinT MVP: Home.

Few notes on how I might implement this:

We can use the https://www.mediawiki.org/wiki/API:Random to get a random page

  • We might want to update the API to take a pagelen as parameter. This can be used to avoid loading very small articles.
  • Select pages in the main namespace and avoid loading redirects
  • It would also be nice to filter on the basis of content model. We only want wikitext.
  • Fetch only a single page

We can use siteMapper.getApi( language ); to fetch the API URL and then make the call to the https://www.mediawiki.org/wiki/API:Random API.

The random topic button will navigate to the confirm topic page with the target language selected. If a source language is selected, then the random topic will be selected from that source language. If no source language is selected, the topic will be selected from a random language falling back to English if no article could be found with the given criteria.

This comment was removed by abi_.

Change #1125635 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/core@master] ApiQueryRandom: Add support for minsize and maxsize

https://gerrit.wikimedia.org/r/1125635

abi_ set the point value for this task to 4.

Change #1125641 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/core@master] ApiQueryRandom: Allow filtering based on content model

https://gerrit.wikimedia.org/r/1125641

abi_ changed the task status from Open to In Progress.Mar 11 2025, 11:33 AM

Change #1125635 merged by jenkins-bot:

[mediawiki/core@master] ApiQueryRandom: Add support for minsize and maxsize

https://gerrit.wikimedia.org/r/1125635

Change #1125641 merged by jenkins-bot:

[mediawiki/core@master] ApiQueryRandom: Allow filtering based on content model

https://gerrit.wikimedia.org/r/1125641

Change #1130318 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/ContentTranslation@master] AX: Implement random topic functionality

https://gerrit.wikimedia.org/r/1130318

abi_ updated Other Assignee, added: hueitan.
abi_ added a subscriber: hueitan.

Change #1130318 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] AX: Implement random topic functionality

https://gerrit.wikimedia.org/r/1130318

@PWaigi-WMF was this tested using the URL : https://ig.m.wikipedia.org/wiki/%E1%BB%8Cp%E1%BB%A5r%E1%BB%A5iche:AutomaticTranslation ? as its not working here yet

can you pls point me to where you tested it. thanks alot

The feature works for me now when i press on the random topic

@abi_ I am now able to Generate a random topic using the random button

Just to confirm ( as shown in the video below) the functionality of this button before I am mark it as pass

  • it generates a random topic and goes off the screen of the user?
  • it generates a random topic from an language wiki ?

@EChukwukere-WMF Please see my comment here: https://phabricator.wikimedia.org/T364905#10616475

Some more clarification:

  1. Based on the target language, we select a random language that can be translated to that target language.
  2. We then get the Wikipedia URL for that language, and then use the API: https://www.mediawiki.org/wiki/API:Random API to fetch a random article with the following criteria:
    • Should have atleast 1000 byes
    • Should not be a redirect
    • Should have content type of Wikitext
    • Should be in the main namespace
  3. We then redirect the user to confirm step with that random article

If the API call in 2) fails to return an article, we set the source language to English and try again once more. If both API calls fail, we show the user an error message.

@abi_ thanks for clarifying this. I will mark this as done. I will keep this ticket for reference later. Thanks again