Worst Case Scenario, How Long Until the Electorate Badge

3

Please login or register to vote for this query.

(click on this box to dismiss)

These data dumps do not include how many questions I have voted up or down. So Assuming that none of the votes I have given are for questions, how many days voting on 30 questions per day do I have until I get the Electorate badge.

Stack Overflow

Q&A for programmers

-- Worst Case Scenario, How Long Until the Electorate Badge
-- These data dumps do not include how many questions I
-- have voted up or down.  So Assuming that none of the votes
-- I have given are for questions, how many days voting on 30 questions
-- per day do I have until I get the Electorate badge.

declare @UserId int = ##UserId##
declare @voteCount int

select @voteCount = u.UpVotes + u.DownVotes
from Users u
where u.Id = @UserId

-- using equivalent of max function given by this answer: http://stackoverflow.com/questions/293804
-- this is used to determine the max days when less than 600 total votes
-- This will give the maximum of 5 days or the amount of days to reach 600

select @voteCount as TotalVotes,
case
    when @voteCount < 600 then ceiling(0.5 * ((600 - @voteCount)/30.0 + 5) + ((600 - @voteCount)/30.0 - 5))
    when exists(select 1 from Badges where UserId = @UserId and Name = 'Electorate') then 0
    else ceiling(@voteCount / (4 * 30.0))
end
as MaxDaysUntilElectorate

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results