-
Notifications
You must be signed in to change notification settings - Fork 0
/
DB_Notes.yml
42 lines (37 loc) · 1.31 KB
/
DB_Notes.yml
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
# Returns durationdata
db.sites.aggregate(
{$match: {name: "Stackoverflow"}},
{$unwind: "$measurements"},
{$group:{
_id: null,
max: { $max: "$measurements.duration" },
min: { $min: "$measurements.duration" },
mean: { $avg: "$measurements.duration" },
}
}
)
# Returns the n first elements
db.sites.aggregate(
{$match: {name: "Stackoverflow"}},
{$unwind: "$measurements"},
{$sort: { "measurements.date": -1 } },
{$limit: 10 },
{$project: { "date": "$measurements.date" , "duration": "$measurements.duration" , "code": "$measurements.code" }}
)
# Returns the counts for every return code
db.sites.aggregate(
{$match: {name: "Stackoverflow"}},
{$unwind: "$measurements"},
{$group: { _id: "$measurements.code", count: { $sum: 1 } }}
)
# Returns all measurements between two dates
db.sites.aggregate(
{$match: {name: "Stackoverflow"}},
{$unwind: "$measurements"},
{$match: { "measurements.date": { $gte: new ISODate( "2022-08-21" ), $lte: new ISODate( "2022-08-22" ) } }},
{$project: { "date": "$measurements.date" , "duration": "$measurements.duration" , "code": "$measurements.code" }}
)
# TODO:
# Timeline (per day)
# Report. Statistical correlation? Time of day / Day of week
# Group data points on a threshold duration