-
Notifications
You must be signed in to change notification settings - Fork 73
Conversation
def get_programs(): | ||
"""Get the counts of how many users belong to each program.""" | ||
users = m.User.objects().only('program_name') | ||
programs = [user.short_program_name for user in users] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we call this program_names
, since it's a list of program names rather than program objects?
|
||
program_frequencies = collections.Counter(programs) | ||
|
||
program_counts = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: And we could probably call this just programs
, since this is essentially a list of program object "abstractions" (since we don't actually have program models in our datastore, but API clients don't need to know that :P)
LGTM |
Should we worry about rate limiting this (and other) endpoints so that we're safer from DoS attacks? |
Well, we're just as likely to be DOS-ed by people hitting our other, "unofficial" endpoints in Though, if we publicize this API, officially document it, and clients other than just our Android app use it, then we can start worrying about it. We probably don't have to worry yet. |
My worry extends to those "unofficial" endpoints as well. I raised my concerns here because this endpoint takes ~2-3 to respond right now and it seemed like a good target. But I agree that we probably don't have to worry about this yet. |
Oooooh. If this endpoint's taking 2-3 seconds to respond, then it totally makes sense (and saves our server's CPU cycles) to write that as a query instead of doing the count in-memory. In SQL it'd be You can make this a GitHub issue if you like. |
Here's a much better link: http://docs.mongodb.org/manual/reference/method/db.collection.group/#calculate-the-sum |
Cool, that looks interesting. |
API endpoint for https://github.com/UWFlow/user_clusters
Allows us to graph this: