gdoteof / election

drupal election module
3 stars 1 forks source link

Indicate Completeness of Results #8

Closed bradley-holt closed 12 years ago

bradley-holt commented 12 years ago

Description

Please indicate "completeness" of results in JSON.

Steps to Reproduce

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

Actual Results

{
   "title":"Ward 1 City Council",
   …
   "results":{
      "Sharon Bushor (I) ":{
         "votes":"416",
         "percent":100,
         "winner":true
      }
   }   …
}

Expected Results

{
   "title":"Ward 1 City Council",
   …
   "results":{
      "Sharon Bushor (I) ":{
         "votes":"416",
         "percent":100,
         "winner":true,
         "complete":true,
      }
   }   …
}

Additional Comments

In HTML, this can be indicated with a class of complete on the result (the same place where the winner class goes). It may turn out that we actually do not need this directly at all, since the concept of "complete" is really used to derive other things. Also, I realize that this is at the individual result level rather than at the results level (this really applies to all results, not each individual result) which is not ideal, but should work.

acrawford commented 12 years ago

I was going to post this in issue #6, but noticed @bradley-holt starting a new issue.

So, I think this is the last outstanding issue on the Drupal/API side. With the timeline we are under to get this on live for testing and Town Meeting Day setup before the 18th of February, I am open to suggestions. Geoff is also out of the picture starting Feb. 12th.

Correct me if I am off base here:

Completeness:

The complete flag is there for each combination of district_nid and ballot_item_nid that has been defined in Drupal through node associations. To eliminate the potential for duplicate counting in issue #3 that can result from associating a ballot item at multiple district levels and improper data entry at higher district levels than we are collecting data, we want to have the completeness information from the most granular level recursively available to us at higher district levels.

Aside -This behavior seems desirable in a General Election as we may have different ballot items where we enter/receive data at different levels of granularity -county judicial election .vs "representative district" election-, not just the lowest levels. end Aside

At these higher district levels it makes Bradley's code more simple and efficient if he can request just the results of a particular ballot item at these higher district levels. It is also useful/necessary to have access to the completeness and winner flags here.

Because a fix for issue #3 may involve an overhaul of the current recursive results aggregation algorithm, i think @gdoteof requested it be tabled in issue #3. is this true?

We can add a vocabulary to associate terms "leaf" or "composite" with districts.

Is it true that all data entry (lowest level) districts are leaf for Town Meeting Day? I believe that this is the case as all towns are leaf, except Burlington, which is composite and made only of leafs, (Wards 1-7). If all lowest level sub-districts are leaf districts and the district_nid ballot_item_nid pair are complete == 1 in all sub districts, then the aggregated districts are also complete. Yes? If that is the case, can the complete flag then be set for a whole district_nid and empty ballot item nid ? It looks as though it can... if so that should get us completeness info at the composite district level.

Winning Method / Winner Displayed:

since @gdoteof is now calculating this in the Drupal module, and tabulation methods are selected at the data-entry stage, the winner is simply output in the base district level results for that ballot item. can we use the same methodology as above to determine the winner at composite district levels? it seems not, as we need to re-apply the methodology to the totals, not check to see if the ballot item option is a "winner" in all sub-districts.

ideas?

gdoteof commented 12 years ago

If that is the case, can the complete flag then be set for a whole district_nid and empty ballot item nid ? It looks as though it can... if so that should get us completeness info at the composite district level.

I am not sure what you mean by this @acrawford.. do you mean literally in the DB to have a row with NULL for the ballot_item_nid ?

All of your Yes?'s are indeed yeses, as far as I can tell.

I guess maybe I am going to have to bite the bullet and just create a link for the aggregated results.

acrawford commented 12 years ago

well, yes that was my original thought, as no ballot items are associated with the upper level district, there is nothing to put in that ballot_item field of the "composite" district record. If the complete flag is set for a whole district_nid and empty ballot item nid, then if there were ballot_items entered at that higher district level, then you would need to test for both district_nid = # and ballot_item_nid = NULL and complete = 1 as well as for district_nid and ballot_item_nid (for those ballot items associated at that higher level) and complete = 1

maybe I need some coffee... maybe if you are creating a link for aggregated results it doesn't matter... the project that won't die ;)

I sent you an e-mail with the screenshots that made me think of this idea. -andy

gdoteof commented 12 years ago

ah yes. a bug with the potential to be a feature. that shouldn't be happening! i think it is better to have implicit parent-district completeness rather than explicit. I will figure out why that checkbox is there

bradley-holt commented 12 years ago

I'm just catching up with this now, but it looks like you have it under control. Let me know if you need anything from me.

gdoteof commented 12 years ago

929438b adds complete fields to individual ballot items

gdoteof commented 12 years ago

36723d8 adds complete fields to summed ballot items

acrawford commented 12 years ago

both commits are live on dev. Thanks for that work geoff! looks like it is working well.

gdoteof commented 12 years ago

dca0430 adds the complete class to the HTML