-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
[back][ext] feat: recommendations API can now return random entities #1876
Conversation
I've been able to significantly improve the performance by removing the |
the reco seems to be random enough, and this will have a positive impact of the API (the cache will be hit more often)
…m... ...entities anymore. use the /recommendations/random/ instead
7713d33
to
1371bd6
Compare
The check |
@@ -18,4 +18,5 @@ | |||
COMPARISON_MAX = 10.0 | |||
|
|||
# Default weight for a criteria in the recommendations | |||
# FIXME: the default weight used by the front end is 50, not 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They don't necessarily need to be the same. The backend can assume 10 when nothing is specified & the frontend can initialize a user's search by default with a value of 50.
I vaguely remember discussing with @amatissart to make it 0 by default. I don't remember well what makes a criteria included or not in the scores used for ranking.
... in the /recommendations/random/ API. This parameter is currently not supported by the view, so it's useless to keep using it to build the cache key.
Description
This PR adds two features:
(1) A new API
polls/{name}/recommendations/random/
that returns random recommendations, designed to be more efficient than the regular recommendations route.(2) The browser extension now uses this new API to improve the loading time of recommendations and their diversity.
context
This PR aims to reduce the number of latency alerts triggered by the API recommendations, by providing API clients, such as the browser extension, an alternative and efficient way to request random recommended entities.
Those latency alerts are currently triggered by the browser extension, when fetching the top 250 of all time recommendations to perform a random selection. Thanks to the new API, the extension doesn't need to fetch a big amount of entities to display a diverse bundle of entities.
Note that the new API is more efficient because it uses a simple SQL query that provides less features than the regular recommendations route:
ℹ️ consequences and important changes
This PR significantly changes the strategy used by browser extension to display diverse entities.
(a) Before, only the top 250 of all time recommendations could be displayed. Now all recommended videos have a chance to be displayed, even those with a Tournesol score of 20.1, like on the web site.
(b) The number of cached recommendation results requested by the extension will increase from 2 every 10 minutes (for a given set of languages) to ~ 40, up to a lot more depending on how many time the users refresh their recommendations with the extension refresh button. This may impact our infrastructure.
to-do
back end - /recommendations/
back end - /recommendations/random/
random
parameter in the metadata?extension
random
for each instance ofTournesolRecommendations
random
vary for each refreshlimit
parameters for more randomnessChecklist