NYCPython / wheretomeetup

Connecting Meetup organizers with hosts and sponsors.
http://www.wheretomeetup.com
BSD 3-Clause "New" or "Revised" License
5 stars 5 forks source link

A few model questions #52

Closed Julian closed 12 years ago

Julian commented 12 years ago

@dcrosta Hey :).

If you get a minute, can you clarify the motivation for moving the API's lat and lon properties into loc on the User model (currently happening inside sync_user). If there's a reason for it, I'm gonna move it onto the model, but if not, we can just get rid of it [and replace it with either nothing, or a property if you like having both available].

Also, for why the id properties are changed to _id on all the models, since that also adds a bit of complexity over just being able to use the API responses as we get them. Here too I think if there's reason to do so (I apologize for not knowing anything whatsoever about Mongo in case that's the reason), I'm gonna give Model a from_api_response method to do that mangling, but we can leave that out too if it isn't so necessary.

dcrosta commented 12 years ago

Both are due to constraints of MongoDB:

Rather than taking too much time to refactor the Model class tree now, I want to spend some time thinking about whether it offers us anything, or if we can remove it. The initial idea was that we could do a lot with load(), save(), and refresh(), but we've sinced moved to doing more with "bulk" operations (API queries and MongoDB finds that return multiple entities)

dirn commented 12 years ago

_id is Mongo's version of a primary key. It is a unique value associated with each document. By default, Mongo will store an ObjectId in the field. We opted to leverage the primary keys provided by meetup.

The reason we opted to use loc is that Mongo allows for running 2d queries on points.

dirn commented 12 years ago

And of course Dan's answer sounds better than mine. :smile:

Julian commented 12 years ago

Ah awesome, OK. Good to know. So leaving things as they are then. Sounds like you have a plan then, so I'm going to leave all of the model stuff alone here.

dcrosta commented 12 years ago

It's more like a plan to come up with a plan.

Bear in mind we built this in one feverish 12-hour session. You're right to question our decisions :)

dirn commented 12 years ago

Every time I look at the code we wrote that day I cringe, especially when I need to use it for something new.