Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a suitable random button to every aspect #284

Closed
Daniel-Mietchen opened this issue Mar 31, 2018 · 3 comments · Fixed by #2301
Closed

Add a suitable random button to every aspect #284

Daniel-Mietchen opened this issue Mar 31, 2018 · 3 comments · Fixed by #2301
Assignees
Labels
aspects the way Scholia looks at Wikidata data usability trying to minimize bad experiences while using Scholia

Comments

@Daniel-Mietchen
Copy link
Member

E.g. we currently have it at
https://tools.wmflabs.org/scholia/author/
but not at
https://tools.wmflabs.org/scholia/work/ .

@Daniel-Mietchen
Copy link
Member Author

@Daniel-Mietchen Daniel-Mietchen added the aspects the way Scholia looks at Wikidata data label Apr 5, 2018
@Daniel-Mietchen Daniel-Mietchen added the usability trying to minimize bad experiences while using Scholia label Aug 29, 2018
@Daniel-Mietchen
Copy link
Member Author

Here is a minimal example of a query that could support a random button:

SELECT ?item 
WHERE
{
  SERVICE bd:sample { ?samplepub wdt:P50 ?item. bd:serviceParam bd:sample.limit 1 }
}
# timestamp X

The timestamp X part is there to circumvent the WDQS cache and would have to be added via Python or JavaScript, in terms of Unix time or similar.

This setup is easily modifiable for other aspects but I chose author here because that is our current implementation and also discussed in #586 and #1062 .

Depending on how random we would want the button (or variants thereof) to be, we could also add some filtering or prioritizing, e.g. as per this query variant:

SELECT ?item ?itemLabel ?itemDescription ?pub ?st ?ids ?sl (COUNT (DISTINCT ?work) AS ?pubs)
WHERE
{
  SERVICE bd:sample { ?pub wdt:P50 ?item. bd:serviceParam bd:sample.limit 42 }
 # OPTIONAL 
  { ?item wikibase:statements ?st ; wikibase:identifiers ?ids ; wikibase:sitelinks ?sl }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?work wdt:P50 ?item. 
}
GROUP BY ?item ?itemLabel ?itemDescription ?pub ?st ?ids ?sl ?pubs
ORDER BY DESC(?st * ?pubs * (?sl + 1) * (?ids + 1 ))
#LIMIT 1

@fnielsen
Copy link
Collaborator

The current hack in random_author is reasonably fast, and can also be used for works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aspects the way Scholia looks at Wikidata data usability trying to minimize bad experiences while using Scholia
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants