Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Add /programs endpoint to API #78

Merged
merged 1 commit into from
Feb 27, 2014
Merged

Add /programs endpoint to API #78

merged 1 commit into from
Feb 27, 2014

Conversation

jswu
Copy link
Member

@jswu jswu commented Feb 27, 2014

API endpoint for https://github.com/UWFlow/user_clusters

Allows us to graph this:
screen shot 2014-02-27 at 2 42 30 am

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]
Copy link
Member

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 = []
Copy link
Member

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)

@divad12
Copy link
Member

divad12 commented Feb 27, 2014

LGTM

jswu added a commit that referenced this pull request Feb 27, 2014
Add /programs endpoint to API
@jswu jswu merged commit 3284e37 into master Feb 27, 2014
@jswu
Copy link
Member Author

jswu commented Feb 27, 2014

Should we worry about rate limiting this (and other) endpoints so that we're safer from DoS attacks?

@jswu jswu deleted the user-clustering branch February 27, 2014 07:56
@divad12
Copy link
Member

divad12 commented Feb 27, 2014

Well, we're just as likely to be DOS-ed by people hitting our other, "unofficial" endpoints in server.py.

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.

@jswu
Copy link
Member Author

jswu commented Feb 27, 2014

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.

@divad12
Copy link
Member

divad12 commented Feb 27, 2014

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 COUNT and GROUP BY, in Mongo there's http://docs.mongodb.org/manual/aggregation/

You can make this a GitHub issue if you like.

@divad12
Copy link
Member

divad12 commented Feb 27, 2014

@jswu
Copy link
Member Author

jswu commented Feb 27, 2014

Cool, that looks interesting.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants