-
Notifications
You must be signed in to change notification settings - Fork 1
/
stats.js
54 lines (42 loc) · 1.92 KB
/
stats.js
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
54
const table = require("table").table;
const mongoose = require("mongoose");
const Datasets = require("./models/dataset").model;
const TimeSeries = require("./models/timeSeries").model;
const Projects = require("./models/project").model;
const LabelDefinitions = require("./models/labelDefinition").model;
const Labels = require("./models/labelType").model;
const config = require("config");
const avg = (arr) => arr.reduce( ( p, c ) => p + c, 0 ) / arr.length;
const table_data = [];
(async () => {
await mongoose.connect(config.db, { useNewUrlParser: true });
const numProjects = await Projects.count({});
table_data.push(["#Projects", numProjects]);
const numDatasets = await Datasets.count({});
table_data.push(["#Datasets", numDatasets]);
const numTimeSeries = await TimeSeries.count({});
table_data.push(["#TimeSeries", numTimeSeries]);
const timeSeries_length = (await TimeSeries.find({}, "data")).map(
(elm) => elm.data.length
)
table_data.push(["Max TimeSeries_length", Math.max(...timeSeries_length)])
table_data.push(["Min TimeSeries_length", Math.min(...timeSeries_length)])
table_data.push(["Avg TimeSeries_length", Math.ceil(avg(timeSeries_length))])
const numLabelDefinitions = await LabelDefinitions.count({});
table_data.push(["#Labelings", numLabelDefinitions]);
const numLabels = await Labels.count({});
table_data.push(["#Labels", numLabels]);
const dataset_labelings = (await Datasets.find({}, "labelings"))
.map((elm) => elm.labelings)
.map((elm) => elm.map((d) => d.labels.length))
.flat()
.reduce((p, v) => p + v, 0);
table_data.push(["#Labels on datasets", dataset_labelings]);
const dataset_noLabels = (await Datasets.find({}, "labelings"))
.map((elm) => elm.labelings)
.filter((elm) => !elm.length).length;
console.log(dataset_noLabels);
table_data.push(["#Datasets with no labels", dataset_noLabels]);
console.log(table(table_data));
process.exit();
})();