Change popular page to reduce value of mass likes

Previously each time you liked something it added 1 point to that post.
That's fine, but it meant that if someone posted 10x more likes then
they'd have 10x more influence that others. I tried to reduce this,
making sure that everyone has exactly 1 influence, but it meant that
when someone only liked 1 thing then it's a *very* powerful like.

I think it's a nice middle ground to divide each point by (1 + ln(x)),
where x is the total number of likes that someone has made. This means:

- 1 like = 1 point
- 2 likes = 1.69 points (0.84 each)
- 4 likes = 2.38 points (0.59 each)
- 8 likes = 3.07 points (0.38 each)
- 16 likes = 3.77 points (0.23 each)
- 32 likes = 4.46 points (0.14 each)
- 64 likes = 5.15 points (0.08 each)
This commit is contained in:
Christian Bundy 2019-12-07 11:43:24 -08:00
parent 284471b9be
commit dbdf5c847f
No known key found for this signature in database
GPG Key ID: EB541AAEF4366237
1 changed files with 28 additions and 4 deletions

View File

@ -344,13 +344,20 @@ const post = {
pull.filter((msg) => {
return typeof msg.value.content === 'object' &&
typeof msg.value.content.vote === 'object' &&
typeof msg.value.content.vote.link === 'string'
typeof msg.value.content.vote.link === 'string' &&
typeof msg.value.content.vote.value === 'number'
}),
pull.reduce((acc, cur) => {
const author = cur.value.author
const target = cur.value.content.vote.link
const value = cur.value.content.vote.value
const old = acc[target] || 0
acc[target] = old + 1
if (acc[author] == null) {
acc[author] = {}
}
// Only accept values between -1 and 1
acc[author][target] = Math.max(-1, Math.min(1, value))
return acc
}, {}, (err, obj) => {
@ -362,7 +369,24 @@ const post = {
// stream much slower than it needs to be. Also, we should probably
// be indexing these rather than building the stream on refresh.
const arr = Object.entries(obj)
const adjustedObj = Object.entries(obj)
.reduce(
(acc, [author, values]) => {
if (author === myFeedId) {
return acc
}
const entries = Object.entries(values)
const total = 1 + Math.log(entries.length)
entries.forEach(([link, value]) => {
acc[link] += value / total
})
return acc
}
)
const arr = Object.entries(adjustedObj)
const length = arr.length
pull(