gdoteof / election

drupal election module
3 stars 1 forks source link

Winning Threshold Needed #12

Closed bradley-holt closed 12 years ago

bradley-holt commented 12 years ago

Description

Please include the winning threshold, if applicable.

Steps to Reproduce

curl 'https://example.org/town-meeting-season-2011/city-of-burlington/burlington-mayor' \
-H 'Accept: application/json'

Actual Results

{
   "title":"Burlington Mayor",
   …
   "results":{
      "Miro_Weinberger":{
         "votes":121,
         "complete":false
      },
      "Bob_Kiss":{
         "votes":232,
         "complete":false
      },
      "Kurt_Wright":{
         "votes":156,
         "complete":false
      }
   }
}

Expected Results

{
   "title":"Burlington Mayor",
   …
   "results":{
      "Miro_Weinberger":{
         "votes":121,
         "winning_threshold":204,
         "complete":false
      },
      "Bob_Kiss":{
         "votes":232,
         "winning_threshold":204,
         "complete":false
      },
      "Kurt_Wright":{
         "votes":156,
         "winning_threshold":204,
         "complete":false
      }
   }
}

Additional Comments

This is based on the explicit winning threshold (40% for Burlington Mayor), not the number of votes at which the "winner" flag would switch from false to true (e.g. plurality without an explicit winning threshold or plurality plus winning threshold). If there is no explicit winning threshold then this property should be excluded.

I'm not sure yet how this would be presented in the HTML as it will only be included in the chart as a visual indicator.

acrawford commented 12 years ago

I'm not sure we can come up with a winning threshold if we don't know the total number of voters that voted on the Ballot Item. As the results come in, the threshold will go up as the total number of voters go up... but I don't think that increasing number will be a good indication of how close a candidate is to winning. It might be no better than just a straight percentage, and sometimes there are under-votes on certain ballot items, so even if we had the total number of voters, the calculation might not be accurate... what do you think?

bradley-holt commented 12 years ago

What if we only used the winning threshold data on the charts for Complete Results? Once the results are "complete" then the numbers shouldn't change again.

acrawford commented 12 years ago

That does make sense.

gdoteof commented 12 years ago

f730cd2 should fix this

acrawford commented 12 years ago

code updated on live and dev, looking good.

bradley-holt commented 12 years ago

I would expect the winning threshold to be an integer. I believe that always rounding up would be a correct way of making sure that these values are integers since the winning threshold is the minimum number of votes required to win. For example, if the winning threshold is 2017.96 then the candidate really needs to get at least 2018 votes in order to win.

For the Burlington Mayor's election at the City of Burlington, I'm seeing the following votes:

These votes total 6303, 40% of which is 2521.2 (2522 rounded up) but the winning threshold is listed as 2017.96 which is about 32% of the total number of votes. I would expect the winning threshold to be 2522.

acrawford commented 12 years ago

I think I edited that in testing that I was doing before geoff's most recent commits. I changed the threshold to 32% to see if I could trigger the winner labels at various levels without changing result data sorry. will switch this back to 40%.

acrawford commented 12 years ago

yup, that was it, changed back to 40.


"results": {
        "Kurt_Wright": {
            "votes": 2450,
            "percent": 38.9,
            "complete": true,
            "winning_threshold": 2522.2
        },
        "Bob_Kiss": {
            "votes": 1982,
            "percent": 31.4,
            "complete": true,
            "winning_threshold": 2522.2
        },
        "Miro_Weinberger": {
            "votes": 1871,
            "percent": 29.7,
            "complete": true,
            "winning_threshold": 2522.2
        }
    }
}
acrawford commented 12 years ago

fb24496 fixes the decimal thresholds i believe, it is live on dev.


{"results": {
        "Kurt_Wright": {
            "votes": 2450,
            "percent": 38.9,
            "complete": true,
            "winning_threshold": 2522
        },
        "Bob_Kiss": {
            "votes": 1982,
            "percent": 31.4,
            "complete": true,
            "winning_threshold": 2522
        },
        "Miro_Weinberger": {
            "votes": 1871,
            "percent": 29.7,
            "complete": true,
            "winning_threshold": 2522
        }
    }
}
bradley-holt commented 12 years ago

Ah, that explains it! I thought it might just be the test data, but I figured it was best to open a ticket and not have it be an issue than the other way around.