From 53ed0774e63f3063c853b4328eb3c049f2373a37 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 9 Oct 2020 13:48:13 +0100 Subject: [PATCH] Voting logic --- posts.py | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/posts.py b/posts.py index 11f4f7b1..2a05687a 100644 --- a/posts.py +++ b/posts.py @@ -2935,28 +2935,31 @@ def createBoxIndexed(recentPostsCache: {}, print('Arrival: mins ' + \ str(timeDiffMins) + ' ' + str(votingTimeMins)) # has the voting time elapsed? - if timeDiffMins > votingTimeMins: - # if there a votes file for this post? - votesFilename = \ - locateNewsVotes(baseDir, domain, postFilename) - if votesFilename: - # load the votes file and count the votes - votesJson = loadJson(votesFilename, 0, 2) - if votesJson: - if not positiveVoting: - if votesOnNewswireItem(votesJson) >= \ - newswireVotesThreshold: - # Too many veto votes. - # Continue without incrementing - # the posts counter - continue - else: - if votesOnNewswireItem < \ - newswireVotesThreshold: - # Not enough votes. - # Continue without incrementing - # the posts counter - continue + if timeDiffMins < votingTimeMins: + # voting is still happening, so don't add this + # post to the timeline + continue + # if there a votes file for this post? + votesFilename = \ + locateNewsVotes(baseDir, domain, postFilename) + if votesFilename: + # load the votes file and count the votes + votesJson = loadJson(votesFilename, 0, 2) + if votesJson: + if not positiveVoting: + if votesOnNewswireItem(votesJson) >= \ + newswireVotesThreshold: + # Too many veto votes. + # Continue without incrementing + # the posts counter + continue + else: + if votesOnNewswireItem < \ + newswireVotesThreshold: + # Not enough votes. + # Continue without incrementing + # the posts counter + continue # Skip through any posts previous to the current page if postsCtr < int((pageNumber - 1) * itemsPerPage):