-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdata_af.js
More file actions
53 lines (45 loc) · 1.29 KB
/
data_af.js
File metadata and controls
53 lines (45 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env mongo
var compare = function (x, y) { return y.count - x.count };
db = new Mongo().getDB("ccanalysis");
var collection = db.getCollection(project);
if (undefined == collection)
return;
var result = {
project : project,
};
var filter = {
_class : "clone.analysis.similarity.StaticCallFlowMatchSet",
isHighPriority : true
};
result.data = collection.aggregate(
{ $match : filter },
{ $unwind : "$set" },
{ $group : {
_id : {
_id : "$_id",
packageCount : "$packageCount",
classCount : "$classCount"
},
asserts : { $first : { $size : "$set.staticCalls" } },
methods : { $sum : 1 }
}
},
{ $project : {
_id : "$_id._id",
packages : "$_id.packageCount",
classes : "$_id.classCount",
asserts : 1,
methods : 1
},
},
{ $sort : {
asserts : -1,
methods : 1,
packages : 1,
classes : 1
}
}
).toArray();
for (var i = 0; i < result.data.length; ++i)
result.data[i]._id = result.data[i]._id.valueOf();
printjson(result);