gdoteof / election

drupal election module
3 stars 1 forks source link

Percentage Shown for Partial Results #9

Closed bradley-holt closed 12 years ago

bradley-holt commented 12 years ago

Description

Please do not show percentage or indication of the winner for "Partial Results". Since these are "Partial Results", the percentage and indication of winners will be misleading to users.

Steps to Reproduce

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

Actual Results

{
   "title":"Burlington Mayor",
   …
   "results":{
      "Miro Weinberger":{
         "votes":"121",
         "percent":23.8,
         "winner":false,
         "complete":false
      },
      "Bob Kiss":{
         "votes":"232",
         "percent":45.6,
         "winner":false,
         "complete":false
      },
      "Kurt Wright":{
         "votes":"156",
         "percent":30.6,
         "winner":false,
         "complete":false
      }
   }
}

Expected Results

{
   "title":"Burlington Mayor",
   …
   "results":{
      "Miro Weinberger":{
         "votes":"121",
         "complete":false
      },
      "Bob Kiss":{
         "votes":"232",
         "complete":false
      },
      "Kurt Wright":{
         "votes":"156",
         "complete":false
      }
   }
}

Additional Comments

The percent column should also be removed in the HTML version (as well as the winner class, although that may be working correctly already).

gdoteof commented 12 years ago

30c0ea1 fixes this

gdoteof commented 12 years ago

oops. as i was submitting i saw you wanted the column removed. i replaced the percent number with 'n/a'

gdoteof commented 12 years ago

732ea61

bradley-holt commented 12 years ago

Works for me now.

bradley-holt commented 12 years ago

For referendums, the percentage display seems to be working the opposite of how it should. Compare:

  1. https://example.org/town-meeting-season-2011/ward-1/burlington-school-budget
  2. https://example.org/town-meeting-season-2011/city-of-burlington/burlington-school-budget

Number 1 is at the ward level so should not have percentage shown, but does. Number 2 is at the municipal level so should have percentage show, but does not.

gdoteof commented 12 years ago

This appears to be working correctly now.

We are still showing percentages for 'partial' results (ie for "just" ward-1) when those partial results are complete. That is, if ward 1 has it's "complete" checkbox checked, we are going to show the percetnages, because ward 1 is complete.

As of now, we don't have a way to distinguish as the district-ballot item level whether or not it is part of a 'larger whole' or not. that is, ward-1/budget is not aware that there is a ward-2/budget that it is 'part' of. If this needs to be adressed, please open another issue.

The issue with city-of-burlington/school-budget not having its percentage was due to the fact that it looks like originally burlington had the school-budget ballot item attached to it directly, and later removed it. It was thus forever locked in the database as 'incomplete'.

I fixed this by doing sanity checks when the election result form is shown (if there are no ballot items to show; it cleans the db) and submitted (it deletes then inserts, rather than updating existing items).

What this means though is that if there is an accidental attachment of a ballot item node to a parent district, AND THE EELECTION RESULT FORM IS SUBMITTED', and then the ballot_item_node is later removed from the parent district, the election result form MUST BE VISITED (if there are no other ballot items) or SUBMITED (if there are other ballot items [this should never be the case for us]).

If there are other parent districts having this issue, they should become fixed by visiting their election_results form.

gdoteof commented 12 years ago

a9e1159

acrawford commented 12 years ago

code updated on live and dev, looking good

bradley-holt commented 12 years ago

Looks good. I've opened up #15 to address the "Partial Results" issue, but we can leave it to @acrawford to determine the priority on that one.