Skip to content

Commit 8f1d6f8

Browse files
authored
Merge pull request #7554 from tangledbytes/utkarsh/fix/analytics-collections
Fix NooBaa usagereports and endpointgroupreports collections
2 parents b171929 + 73a0747 commit 8f1d6f8

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

src/server/analytic_services/endpoint_group_report_indexes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
module.exports = [{
55
fields: {
66
start_time: 1,
7-
aggregated_time: -1,
8-
aggregated_time_range: 1,
7+
end_time: 1,
8+
group_name: 1,
99
},
1010
options: {
1111
unique: false,
1212
}
13-
}, ];
13+
}];

src/server/analytic_services/endpoint_stats_store.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,17 @@ class EndpointStatsStore {
167167

168168
async get_endpoint_group_reports(params) {
169169
dbg.log1('get_endpoint_group_reports', params);
170-
const query = this._format_endpoint_gorup_report_query(params);
170+
const query = this._format_endpoint_group_report_query(params);
171171
return this._endpoint_group_reports.find(query);
172172
}
173173

174174
async clean_endpoint_group_reports(params) {
175175
dbg.log1('clean_endpoint_group_reports', params);
176-
const query = this._format_endpoint_gorup_report_query(params);
176+
const query = this._format_endpoint_group_report_query(params);
177177
return this._endpoint_group_reports.deleteMany(query);
178178
}
179179

180-
_format_endpoint_gorup_report_query(params) {
180+
_format_endpoint_group_report_query(params) {
181181
const { groups, since, till } = params;
182182
const query = {};
183183
if (groups) _.set(query, ['group_name', '$in'], _.castArray(groups));
@@ -196,6 +196,7 @@ class EndpointStatsStore {
196196
group_name: report.endpoint_group,
197197
};
198198
const update = {
199+
$set: selector,
199200
$push: {
200201
endpoints: _.pick(report, [
201202
'hostname',
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
/* Copyright (C) 2016 NooBaa */
22
'use strict';
33

4-
module.exports = [{
5-
fields: {
6-
start_time: 1,
7-
aggregated_time: -1,
8-
aggregated_time_range: 1,
9-
},
10-
options: {
11-
unique: false,
4+
module.exports = [
5+
// There are many other fields in the table but this is a common denominator
6+
// and the hot query uses only these fields.
7+
{
8+
fields: {
9+
start_time: 1,
10+
end_time: 1,
11+
bucket: 1,
12+
},
13+
options: {
14+
unique: false,
15+
}
1216
}
13-
}, ];
17+
];

src/server/bg_services/usage_aggregator.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ async function background_worker() {
112112
const till = moment().subtract(8, 'weeks').valueOf();
113113
dbg.log0('Deleting reports older than', new Date(till));
114114
await EndpointStatsStore.instance.clean_bandwidth_reports({ till });
115+
116+
// Clean endpoint group reports here as well?
117+
await EndpointStatsStore.instance.clean_endpoint_group_reports({ till });
115118
}
116119

117120
function _accumulate_bandwidth(acc, update) {

0 commit comments

Comments
 (0)