Skip to content

Commit

Permalink
Analytics: count flat badges requests.
Browse files Browse the repository at this point in the history
Related to issue #185.
  • Loading branch information
espadrine committed Jun 20, 2014
1 parent 6bf8248 commit ef63de8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ function analyticsAutoLoad() {
}
// In case something happens on the 36th.
analytics.vendorMonthly = new Array(36);
analytics.rawMonthly = new Array(36);
resetMonthlyAnalytics(analytics.vendorMonthly);
analytics.rawMonthly = new Array(36);
resetMonthlyAnalytics(analytics.rawMonthly);
analytics.rawFlatMonthly = new Array(36);
resetMonthlyAnalytics(analytics.rawFlatMonthly);
});
} else {
// Not using Redis.
Expand All @@ -72,9 +74,11 @@ function analyticsAutoLoad() {
} catch(e) {
// In case something happens on the 36th.
analytics.vendorMonthly = new Array(36);
analytics.rawMonthly = new Array(36);
resetMonthlyAnalytics(analytics.vendorMonthly);
analytics.rawMonthly = new Array(36);
resetMonthlyAnalytics(analytics.rawMonthly);
analytics.rawFlatMonthly = new Array(36);
resetMonthlyAnalytics(analytics.rawFlatMonthly);
}
}
}
Expand Down Expand Up @@ -122,6 +126,9 @@ function cache(f) {
// Cache management - no cache, so it won't be cached by GitHub's CDN.
ask.res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
incrMonthlyAnalytics(analytics.vendorMonthly);
if (data.style === 'flat') {
incrMonthlyAnalytics(analytics.rawFlatMonthly);
}

var cacheIndex = match[0] + '?label=' + data.label + '&style=' + data.style;
// Should we return the data right away?
Expand Down

0 comments on commit ef63de8

Please sign in to comment.