mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-29 18:45:48 -05:00
25 lines
863 B
JavaScript
25 lines
863 B
JavaScript
// Print out teacher survey counts by day
|
|
|
|
// Usage:
|
|
// mongo <address>:<port>/<database> <script file> -u <username> -p <password>
|
|
|
|
var surveyDayMap = {};
|
|
var cursor = db['trial.requests'].find({type: 'subscription'});
|
|
while (cursor.hasNext()) {
|
|
var doc = cursor.next();
|
|
var date = doc._id.getTimestamp();
|
|
var day = date.toISOString().substring(0, 10);
|
|
if (!surveyDayMap[day]) surveyDayMap[day] = 0;
|
|
surveyDayMap[day]++;
|
|
}
|
|
|
|
var surveysSorted = [];
|
|
for (var day in surveyDayMap) {
|
|
surveysSorted.push({day: day, count: surveyDayMap[day]});
|
|
}
|
|
surveysSorted.sort(function(a, b) {return b.day.localeCompare(a.day);});
|
|
print("Number of teacher surveys per day:")
|
|
for (var i = 0; i < surveysSorted.length; i++) {
|
|
var stars = new Array(surveysSorted[i].count + 1).join('*');
|
|
print(surveysSorted[i].day + "\t" + surveysSorted[i].count + "\t" + stars);
|
|
}
|