Skip to content

Commit

Permalink
fix(feed): keep feed alive on down votes
Browse files Browse the repository at this point in the history
  • Loading branch information
DEgITx committed Jul 22, 2018
1 parent 99215c6 commit 0e33c93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/background/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,8 @@ module.exports = async ({
if(torrent.good > 0 || torrent.bad > 0)
updateTorrentToDB(torrent)

// update feed
if(record.vote !== 'good')
// update feed only on some good info
if(torrent.good < 1)
return

feed.add(torrent)
Expand Down
5 changes: 3 additions & 2 deletions src/background/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,15 @@ module.exports = class Feed {

_compare(x)
{
const rating = (x && x.good) || 0
const good = (x && x.good) || 0
const bad = (x && x.bad) || 0
const comments = 0
let time = Math.floor(Date.now() / 1000) - x.feedDate

const maxTime = 600000
if(time > maxTime)
time = maxTime
const relativeTime = (maxTime - time) / maxTime
return relativeTime * relativeTime + rating * 1.5 * relativeTime + comments * 4 * relativeTime
return relativeTime * relativeTime + good * 1.5 * relativeTime + comments * 4 * relativeTime - bad * 0.6 * relativeTime
}
}

0 comments on commit 0e33c93

Please sign in to comment.