Teacher survey counts per day script
This commit is contained in:
parent
697b0e9e42
commit
4593b7d864
1 changed files with 25 additions and 0 deletions
25
scripts/analytics/mongodb/queries/teacherSurveyCounts.js
Normal file
25
scripts/analytics/mongodb/queries/teacherSurveyCounts.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// 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);
|
||||||
|
}
|
Reference in a new issue