Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get the top 30 contributors between two releases as a model for ember.js
var SettingsAboutRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, {
model: function () {
var contribStatsUrl = '',
releasesUrl = '',
return ic.ajax.request(releasesUrl).then(function (releases) {
//Divide by 1k to remove milliseconds: GH doesn't use them
from = Date.parse(releases[1].published_at) / 1000;
to = Date.parse(releases[0].published_at) / 1000;
return ic.ajax.request(contribStatsUrl);
}).then(function (contributors) {
//Top 30 contributors, sorted by commits between from and to.
return (contributor) {
//Sum up the number of commits between the latest releases
var numCommits = contributor.weeks.reduce(function (commits, week) {
if (week.w >= from && week.w <= to) {
//Subtract is a hack to sort descending
return commits - week.c;
return commits;
}, 0);
//Map to a template friendlier object
return {
//Add up commits between the two dates.
commits: numCommits
}).sortBy('commits').slice(0, 30);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.