Skip to content

Comment routing semi randomness #980

Locked Answered by metasoarous
LawrenceFulton asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for asking @LawrenceFulton.

In short, we sum up all the weights, pick a random number between 0 and said sum, and then iterate through the comments, summing up all the past weights as we go, and pick the first one that surpasses the randomly selected value (the exact order of operations is slightly different due to performance optimization, but this gives you this gist easily enough). You can see the code that does this here:

polis/server/src/server.js

Lines 7134 to 7158 in 20ab1b3

function selectProbabilistically(comments, priorities, nTotal, nRemaining) {
// Here we go through all of the comments we might select for the user and add their priority values
let l…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@metasoarous
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by colinmegill
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants