mozilla/openbadges — pull request #959 by christensenep (2013-11-26 00:42:52+00:00)
Title: [WIP] Badge metrics endpoint

This adds an endpoint at /badgecounts that provides a JSON listing of each badge that is contained in at least one public collection, along with a count of publicly displayed instances of that badge (unique instances, so the same badge in multiple collections of a single user will still only count as one badge). The badges are grouped by the url in badge._location, so the JSON looks something like:

{
"badges": {
"http://badger.openbadges.org/badge/meta/a-summit-test-badge": 1,
"http://badger.openbadges.org/badge/meta/mozfest-reveler": 2
}
}

This is extremely WIP right now. I mostly just wanted to get this out there to get feedback on whether I've made some grievously incorrect assumptions. In particular, I'm not sure this is the correct way to determine whether two badge instances belong to the same badge class. I'm also not a fan of the endpoint "/badgecounts", though unfortunately there is already a "/stats" endpoint.

This also includes a change to mysql_base.js, to allow query criteria to include arrays of possible values (to create queries like "SELECT * FROM GROUP WHERE ID IN (1,2,3)").

Other things:

- No documentation yet.
- /badgecounts is currently publicly accessible. Should it be?
- Should there be more info in addition to just a location url and a count of badges?