mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Update teacher survey count script
This commit is contained in:
parent
5ea9b6e8af
commit
5975bed348
1 changed files with 5 additions and 2 deletions
|
@ -4,10 +4,13 @@
|
|||
// mongo <address>:<port>/<database> <script file> -u <username> -p <password>
|
||||
|
||||
var surveyDayMap = {};
|
||||
var cursor = db['trial.requests'].find({type: 'subscription'});
|
||||
var cursor = db['trial.requests'].find();
|
||||
while (cursor.hasNext()) {
|
||||
var doc = cursor.next();
|
||||
var date = doc._id.getTimestamp();
|
||||
if (doc.created) {
|
||||
date = doc.created;
|
||||
}
|
||||
var day = date.toISOString().substring(0, 10);
|
||||
if (!surveyDayMap[day]) surveyDayMap[day] = 0;
|
||||
surveyDayMap[day]++;
|
||||
|
@ -17,7 +20,7 @@ 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);});
|
||||
surveysSorted.sort(function(a, b) {return a.day.localeCompare(b.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('*');
|
||||
|
|
Loading…
Reference in a new issue