rgpages / election-2014-general

2014 general election coverage for Lane County, Oregon; developed and curated by The Register-Guard.
http://vote.registerguard.com
0 stars 2 forks source link

JSON data/structure input/output #12

Closed mhulse closed 9 years ago

mhulse commented 10 years ago

Tools to maybe utilize:

  1. Mustache or lodash for templating.
  2. Angular.js JS framework
  3. jQuery
  4. Other?
robertdenton commented 10 years ago

Rob's first go at it:

[
    {
        "contest": "US Senate",
        "total": 400,
        "options": [
            {
                "option":"Yes",
                "votes": 137,
                "percent": 34.25
            },
            {
                "option":"No",
                "votes": 341,
                "percent": 85.25
            }
        ]
    },
    {
        "contest": "US Rep 4th District",
        "total": 500,
        "options": [
            {
                "option":"Yes",
                "votes": 200,
                "percent": 40
            },
            {
                "option":"No",
                "votes": 100,
                "percent": 20
            }
        ]
    }
]
jheasly commented 10 years ago

Add:

mhulse commented 10 years ago

Note to self: For parsing/templating/MVC, http://knockoutjs.com maybe? Need to explore.

mhulse commented 10 years ago

Nice work on this first draft of the JSON output John: http://projects.registerguard.com/ballot/json/

:+1: and adding (above) link to issue for future reference.

jheasly commented 10 years ago

JSONP feed info items to be integrated into display:

mhulse commented 10 years ago

Feed tweaks:

img_1440

jheasly commented 10 years ago

Django - clear cache on model save - the lightweight way (hamfisted — clobbers entire cache — but lightweight ... ) https://gist.github.com/centralniak/1100130 https://github.com/registerguard/django-ad-manager/blob/master/ad_manager/mixins/views.py

Interesting Concentric Sky code (but not really what I'm looking for): https://github.com/concentricsky/django-cachemodel

mhulse commented 9 years ago

Just so I have the key/values:

mhulse commented 9 years ago

Just curious, why do some of the "votes" in this:

http://projects.registerguard.com/ballot/json/region/

Say "None"?

jheasly commented 9 years ago

As for key/values, the JSON(P) feeds have an affiliation_pretty key, where the value is the full name. Does that take care of the issue?

jheasly commented 9 years ago

You get a value of None until a value of 0 gets recorded by an updating script or fat-fingered in via the admin.

mhulse commented 9 years ago

Yup, affiliation_pretty is useful. I am using both actually. IIRC, I ended up checking for !== "none' and !== "" to get around some of the issues I was having. All is good now.

Thanks for clarification.

With that said, I think this issue is complete. Everything has been checked off above lists (just need to refine styles and cross-browser test).

Closing! :+1:

jheasly commented 9 years ago

Thinking about it now, running a python manage.py ballot_test_data_in (then python manage.py ballot_test_data_reset) would've removed the Nones.

I think the Nones must've been the Region races/measures I added late last week and I never inserted/deleted test data into them, so they still had that virgin None state.

mhulse commented 9 years ago

Ah, I see. No worries. 😃

I really want to make sure my JS is updating results correctly, so we'll have to do some thorough checking.