openelections / dashboard

Dashboard for The OpenElections Project.
MIT License
16 stars 4 forks source link

Add ability to track multiple direct data links on Election records? #18

Closed zstumgoren closed 10 years ago

zstumgoren commented 10 years ago

Should we update the Election model to add the ability to track multiple links to raw data files? Currently we only allow a single url in Election.direct_link, but it's quite common to have multiple data files associated with a single Election record. For example, in VA, we have separate files for a pair of state legislative races associated with the Sept. 4, 2012 Election record (right now I'm dropping these links into the Election.note field, which is gross).

Adding support for multiple data source links would allow us to better leverage the metadata API in the core framework, hopefully reducing complexity and increasing consistency in datasource.py implementations.

Two possible implementations:

zstumgoren commented 10 years ago

Ok, I'm also remembering why I punted on this in the original implementation. Adding an M2M to inline Election records on State admin pages was cumbersome. So if we do want to implement this, I'm thinking the quick & dirty route (change Election.direct_link to a text field is the path of least resistance. @dwillis @ghing If that doesn't make you all itch too much, I'd prefer to go that route to avoid getting bogged down in the implementation. Thoughts?

dwillis commented 10 years ago

Fine by me.

ghing commented 10 years ago

Let's try going that route if it ends up causing problems when consuming the metadata, we can revisit. I think you're right that having all metadata, but dirtier is better than having less data but cleaner.

I can also imagine an intermediate solution where we have both a text field and M2M fields and the text field gets parsed out into M2M fields in a post_save hook, avoiding the pain of making things work in the Django admin, but not adding work on the consumer end.

zstumgoren commented 10 years ago

Ok all, I've pushed Election.direct_links changes based on this thread and our offline conversation. Changes include:

Let me know if you have questions or find bugs. Otherwise I'll close this ticket.

ghing commented 10 years ago

I'm happy you thought of splitting direct_links into a list in the API response. That makes a lot of sense and avoids having to decide where the parsing would go in downstream code. Nice design! :smile:

zstumgoren commented 10 years ago

@ghinb Excellent. Glad that works for downstream. Should we remove direct_link API field now or just create a placeholder ticket about removing it after we've ported datasource.py for various states? Of course, if you already know that it won't break anything, let me know and I can just remove it.

ghing commented 10 years ago

We'll need to update a few of the existing datasources, but that should be pretty lightweight. I'll do that today.

zstumgoren commented 10 years ago

Closing this ticket since work has been deployed. The API currently has direct_link and direct_links, for backwards compatibility.