openelections / openelections-core

Core repo for election results data acquisition, transformation and output.
MIT License
176 stars 96 forks source link

Add Party and Office metadata loaders #61

Closed zstumgoren closed 10 years ago

zstumgoren commented 10 years ago

Create openelex/us/fixtures directory and add CSV fixtures for

Let's keep things simple and just create CSVs that can be loaded by standard mongoimport shell command.

ghing commented 10 years ago

@zstumgoren, do the CSV fixtures in e6b9d52 look right in terms of what you were thinking?

A few thoughts, mostly for documentation. I don't want to get bogged down in analysis paralysis:

zstumgoren commented 10 years ago

Haven't checked commit yet, but csvs should mirror the new party and office models on raw result branch.

Let's keep single global offices fixture. It's useful to be able to eyeball them in one place to ensure we apply similar naming conventions across states.

Let's punt on open states api integration for now, but create a placeholder issue to remind us to assess in future.

ghing commented 10 years ago

@zstumgoren, #64 is a pull request into the rawresult branch for this. Once you review and merge I'll update the docs for @dwillis.

ghing commented 10 years ago

@zstumgoren, I'm also a little confused about how this works with EmbeddedDocument models. Won't those be replicated for each of their parent documents? In that case, you can't really access the pre-loaded office and party data from MongoEngine. I guess one way to do it would be to create a EmbeddedOffice class that inherits from both Office and EmbeddedDocument and then just copy over the fields from Office to an embedded EmbeddedOffice doc in your parent doc. Let me know if I'm misunderstanding things.

zstumgoren commented 10 years ago

Woops. I made party and office embedded documents but intended to make them Document subclasses referenced from the Contest model. Otherwise those data loader commands don't make much sense, right? Sorry for the mixup. Feel free to change the parent model in each of those classes on rawresult or i'll make the change later tonight.

ghing commented 10 years ago

@zstumgoren. Just glad I'm understanding things right. You can go ahead and make that change since you've been hacking on the rawresult branch. It shouldn't affect the code I pushed today one way or another. Let me know if I need to make any more changes once you've had a chance to review my pull request.

zstumgoren commented 10 years ago

@ghing Damn, I forgot to add a chamber field on Office that we'll need to populate in the CSV. The name field, which currently appears to contain the chamber, should be populated using a standardized office name. For example, U.S. Senate, U.S. House of Representatives, House of Delegates, State Senate, etc. The chamber field should simply have upper or lower if appropriate (e.g. House of Delegates is lower and State Senate is upper in MD.)

party looks good, though let's use the noun form for name ("Democrat" and "Republican") instead of adjective.

ghing commented 10 years ago

@zstumgoren I can clean up the CSVs. Where can I find the standardized list of office names? I just used the second column of https://github.com/openelections/specs/wiki/Office-Name.

zstumgoren commented 10 years ago

There's no single list that I'm aware of. The names for our target offices will have to be standardized as we add each state. Some can be cribbed from open states, as you pointed out, but for now let's use the list @dwillis created as our starting point. I can add a state field (we'll use 'us' as state for president) and split out the chamber into a separate field. I can make related model changes as well.

ghing commented 10 years ago

@zstumgoren, check out 1cc5aad for fixes to names and adding chamber field.

zstumgoren commented 10 years ago

@ghing nice. looks perfect. thanks!

zstumgoren commented 10 years ago

@ghing just realized you're making these changes on your fork. Can you merge into dev or rawresults branch on openelex when you have a chance? or I can add you as a remote if you're clocked out for the night :)

ghing commented 10 years ago

Just merged PR #64 into rawresult.

ghing commented 10 years ago

@zstumgoren, is this ready to be closed?

ghing commented 10 years ago

@zstumgoren, the docs portion has a pull request in openelections/docs#1. Let me know if this looks right to you.

dwillis commented 10 years ago

I just checked it and it looks good to me, so I merged.