mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-07 10:34:46 -04:00
Analytics code language usage script
This commit is contained in:
parent
604bc48506
commit
a3afba068f
1 changed files with 30 additions and 0 deletions
30
scripts/analytics/mongodb/queries/CodeLanguageUsage.js
Normal file
30
scripts/analytics/mongodb/queries/CodeLanguageUsage.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Print out code language usage based on level session data
|
||||
var total = 0;
|
||||
var languages = {};
|
||||
var startDate = new ISODate("2014-12-01T00:00:00.000Z")
|
||||
db['level.sessions'].aggregate(
|
||||
[
|
||||
{ $match : {
|
||||
//$and: [{codeLanguage: {$exists: true}}, {created : { $gte: startDate}}]
|
||||
codeLanguage: {$exists: true}
|
||||
}
|
||||
},
|
||||
{
|
||||
$group : {
|
||||
_id: "$codeLanguage",
|
||||
total: {$sum: 1}
|
||||
}
|
||||
},
|
||||
{ $sort : { total : -1} }
|
||||
]
|
||||
).result.forEach( function (myDoc) {
|
||||
//print(myDoc)
|
||||
total += myDoc.total;
|
||||
if (!languages[myDoc._id])
|
||||
languages[myDoc._id] = 0
|
||||
languages[myDoc._id] += myDoc.total
|
||||
})
|
||||
print("Total sessions with code languages", total);
|
||||
for (key in languages) {
|
||||
print(key, languages[key], languages[key] / total * 100);
|
||||
}
|
Loading…
Add table
Reference in a new issue