Skip to content

Commit dfef1aa

Browse files
authored
Merge branch 'next' into anna/next
2 parents 9ebd731 + 58bb718 commit dfef1aa

File tree

21 files changed

+234
-124
lines changed

21 files changed

+234
-124
lines changed

api/parts/data/cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ class StreamedCollection {
971971
let [col, last] = await createCollection(this.db, this.name, 1e7);
972972

973973
this.col = col;
974-
this.stream = col.find({_id: {$gt: last}}, {tailable: true, awaitData: true, noCursorTimeout: true, numberOfRetries: -1}).stream();
974+
this.stream = col.find({_id: {$gt: last}}, {tailable: true, awaitData: true, numberOfRetries: -1}).stream();
975975

976976
this.stream.on('data', doc => {
977977
if (this.inserts.indexOf(doc._id.toString()) !== -1) {

api/parts/jobs/job.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,9 +1068,16 @@ class IPCFaçadeJob extends ResourcefulJob {
10681068
this.ipcChannel.remove();
10691069
}, (error) => {
10701070
this.ipcChannel.remove();
1071-
log.e('[%s] Error in IPCFaçadeJob %s: %j / %j', this.job.channel, this.resourceFaçade._id, error, error.stack);
1071+
if (error) {
1072+
log.e('[%s] Error in IPCFaçadeJob %s: %j / %j', this.job.channel, this.resourceFaçade._id, error, error.stack);
1073+
}
1074+
else {
1075+
log.e('[%s] Error in IPCFaçadeJob %s: Unknown error', this.job.channel, this.resourceFaçade._id);
1076+
}
10721077
this.job._finish(error || 'Aborted').catch(()=>{});
1073-
throw error;
1078+
if (error) {
1079+
throw error;
1080+
}
10741081
});
10751082
}
10761083

api/parts/mgmt/apps.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ appsApi.updateAppPlugins = function(params) {
613613
* @returns {boolean} true if operation successful
614614
**/
615615
appsApi.deleteApp = function(params) {
616+
params = params || {};
616617
var argProps = {
617618
'app_id': {
618619
'required': true,

api/parts/mgmt/cms.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,21 @@ function syncCMSDataToDB(params) {
157157
}
158158

159159
cmsApi.saveEntries = function(params) {
160+
161+
var entries = [];
162+
try {
163+
entries = JSON.parse(params.qstring.entries);
164+
}
165+
catch (ex) {
166+
log.e(params.qstring.entries);
167+
common.returnMessage(params, 400, 'Invalid entries parameter');
168+
return;
169+
}
170+
160171
transformAndStoreData(
161172
Object.assign({dataTransformed: true}, params),
162173
null,
163-
JSON.parse(params.qstring.entries),
174+
entries,
164175
function(err1) {
165176
if (err1) {
166177
log.e('An error occured while storing entries in DB: ' + err1);

bin/scripts/drill_index.js

Lines changed: 67 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -32,75 +32,77 @@ Promise.all([plugins.dbConnection("countly"), plugins.dbConnection("countly_dril
3232
countlyDb.close();
3333
console.log("Error occured:", error);
3434
}
35-
var cnt = 0;
36-
results = results.filter(collection => collection && collection.collectionName && collection.collectionName.startsWith("drill_events"));
37-
async.eachSeries(results, function(collection, done) {
38-
cnt++;
39-
console.log("Processing", cnt, "of", results.length, collection.collectionName);
40-
var col = db.collection(collection.collectionName);
41-
col.createIndex({uid: 1}, {background: true}, function() {
42-
console.log("Done", {uid: 1});
43-
if (hashes[collection.collectionName] === "[CLY]_session") {
44-
col.createIndex({ts: 1, "up.cc": 1, uid: 1}, {background: true}, function() {
45-
console.log("Done", "[CLY]_session", {ts: 1, "up.cc": 1, uid: 1});
46-
done();
47-
});
48-
}
49-
else if (hashes[collection.collectionName] === "[CLY]_view") {
50-
col.createIndex({ts: 1, "sg.name": 1}, {background: true}, function() {
51-
console.log("Done", "[CLY]_view", {ts: 1, "sg.name": 1});
52-
done();
53-
});
54-
}
55-
else if (hashes[collection.collectionName] === "[CLY]_crash") {
56-
col.createIndex({ts: 1, "sg.crash": 1}, {background: true}, function() {
57-
console.log("Done", "[CLY]_crash", {ts: 1, "sg.crash": 1});
58-
done();
59-
});
60-
}
61-
else if (hashes[collection.collectionName] === "[CLY]_push_action") {
62-
col.createIndex({ts: 1, "sg.i": 1, uid: 1}, {background: true}, function() {
63-
console.log("Done", "[CLY]_push_action", {ts: 1, "sg.i": 1});
64-
done();
65-
});
66-
}
67-
else if (hashes[collection.collectionName] === "[CLY]_star_rating") {
68-
col.createIndex({ts: 1, "sg.widget_id": 1, "sg.rating": 1, uid: 1}, {background: true}, function() {
69-
console.log("Done", "[CLY]_star_rating", {ts: 1, "sg.widget_id": 1, "sg.rating": 1});
70-
done();
71-
});
72-
}
73-
else if (hashes[collection.collectionName] === "[CLY]_nps") {
74-
col.createIndex({ts: 1, "sg.widget_id": 1, "sg.rating": 1, uid: 1}, {background: true}, function() {
75-
console.log("Done", "[CLY]_nps", {ts: 1, "sg.widget_id": 1, "sg.rating": 1});
76-
done();
77-
});
78-
}
79-
else if (hashes[collection.collectionName] === "[CLY]_survey") {
80-
col.createIndex({ts: 1, "sg.widget_id": 1, uid: 1}, {background: true}, function() {
81-
console.log("Done", "[CLY]_survey", {ts: 1, "sg.widget_id": 1});
82-
done();
83-
});
84-
}
85-
else {
86-
col.createIndex({ts: 1}, {background: true}, function() {
87-
console.log("Done", {ts: 1});
35+
else {
36+
var cnt = 0;
37+
results = results.filter(collection => collection && collection.collectionName && collection.collectionName.startsWith("drill_events"));
38+
async.eachSeries(results, function(collection, done) {
39+
cnt++;
40+
console.log("Processing", cnt, "of", results.length, collection.collectionName);
41+
var col = db.collection(collection.collectionName);
42+
col.createIndex({uid: 1}, {background: true}, function() {
43+
console.log("Done", {uid: 1});
44+
if (hashes[collection.collectionName] === "[CLY]_session") {
45+
col.createIndex({ts: 1, "up.cc": 1, uid: 1}, {background: true}, function() {
46+
console.log("Done", "[CLY]_session", {ts: 1, "up.cc": 1, uid: 1});
47+
done();
48+
});
49+
}
50+
else if (hashes[collection.collectionName] === "[CLY]_view") {
51+
col.createIndex({ts: 1, "sg.name": 1}, {background: true}, function() {
52+
console.log("Done", "[CLY]_view", {ts: 1, "sg.name": 1});
53+
done();
54+
});
55+
}
56+
else if (hashes[collection.collectionName] === "[CLY]_crash") {
57+
col.createIndex({ts: 1, "sg.crash": 1}, {background: true}, function() {
58+
console.log("Done", "[CLY]_crash", {ts: 1, "sg.crash": 1});
59+
done();
60+
});
61+
}
62+
else if (hashes[collection.collectionName] === "[CLY]_push_action") {
63+
col.createIndex({ts: 1, "sg.i": 1, uid: 1}, {background: true}, function() {
64+
console.log("Done", "[CLY]_push_action", {ts: 1, "sg.i": 1});
65+
done();
66+
});
67+
}
68+
else if (hashes[collection.collectionName] === "[CLY]_star_rating") {
69+
col.createIndex({ts: 1, "sg.widget_id": 1, "sg.rating": 1, uid: 1}, {background: true}, function() {
70+
console.log("Done", "[CLY]_star_rating", {ts: 1, "sg.widget_id": 1, "sg.rating": 1});
71+
done();
72+
});
73+
}
74+
else if (hashes[collection.collectionName] === "[CLY]_nps") {
75+
col.createIndex({ts: 1, "sg.widget_id": 1, "sg.rating": 1, uid: 1}, {background: true}, function() {
76+
console.log("Done", "[CLY]_nps", {ts: 1, "sg.widget_id": 1, "sg.rating": 1});
77+
done();
78+
});
79+
}
80+
else if (hashes[collection.collectionName] === "[CLY]_survey") {
81+
col.createIndex({ts: 1, "sg.widget_id": 1, uid: 1}, {background: true}, function() {
82+
console.log("Done", "[CLY]_survey", {ts: 1, "sg.widget_id": 1});
83+
done();
84+
});
85+
}
86+
else {
87+
col.createIndex({ts: 1}, {background: true}, function() {
88+
console.log("Done", {ts: 1});
89+
done();
90+
});
91+
}
92+
});
93+
}, function() {
94+
console.log("Fixing indexes on eventTimes collections");
95+
async.eachSeries(apps, function(app, done) {
96+
countlyDb.collection('eventTimes' + app._id).ensureIndex({"uid": 1}, function() {
8897
done();
8998
});
90-
}
91-
});
92-
}, function() {
93-
console.log("Fixing indexes on eventTimes collections");
94-
async.eachSeries(apps, function(app, done) {
95-
countlyDb.collection('eventTimes' + app._id).ensureIndex({"uid": 1}, function() {
96-
done();
99+
}, function() {
100+
db.close();
101+
countlyDb.close();
102+
console.log("Drill index finished");
97103
});
98-
}, function() {
99-
db.close();
100-
countlyDb.close();
101-
console.log("Drill index finished");
102104
});
103-
});
105+
}
104106
});
105107
});
106108
});

bin/scripts/fix-data/recheck_merges_new.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ Promise.all([pluginManager.dbConnection("countly"), pluginManager.dbConnection("
172172
}
173173
totalProcessedUsers[app._id]++;
174174
}
175-
await addRecheckedFlag(app._id, user.uid);
175+
if (user && user.uid) {
176+
await addRecheckedFlag(app._id, user.uid);
177+
}
176178
}
177179
console.log("Processed users for app", app.name, ": ", totalProcessedUsers[app._id]);
178180
}

frontend/express/public/core/app-management/javascripts/countly.views.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -381,26 +381,28 @@
381381
},
382382
dataType: "json",
383383
success: function(data) {
384-
data.locked = false;
385-
countlyGlobal.apps[data._id] = data;
386-
countlyGlobal.admin_apps[data._id] = data;
387-
Backbone.history.appIds.push(data._id + "");
388-
countlyGlobal.apps[data._id].image = "appimages/" + data._id + ".png?" + Date.now().toString();
389-
self.appList.push({
390-
value: data._id + "",
391-
label: data.name
392-
});
393-
self.$store.dispatch("countlyCommon/addToAllApps", data);
394-
if (self.firstApp) {
395-
countlyCommon.ACTIVE_APP_ID = data._id + "";
396-
app.onAppManagementSwitch(data._id + "", data && data.type || "mobile");
397-
self.$store.dispatch("countlyCommon/updateActiveApp", data._id + "");
398-
app.initSidebar();
384+
if (data && data._id) {
385+
data.locked = false;
386+
countlyGlobal.apps[data._id] = data;
387+
countlyGlobal.admin_apps[data._id] = data;
388+
Backbone.history.appIds.push(data._id + "");
389+
countlyGlobal.apps[data._id].image = "appimages/" + data._id + ".png?" + Date.now().toString();
390+
self.appList.push({
391+
value: data._id + "",
392+
label: data.name
393+
});
394+
self.$store.dispatch("countlyCommon/addToAllApps", data);
395+
if (self.firstApp) {
396+
countlyCommon.ACTIVE_APP_ID = data._id + "";
397+
app.onAppManagementSwitch(data._id + "", data && data.type || "mobile");
398+
self.$store.dispatch("countlyCommon/updateActiveApp", data._id + "");
399+
app.initSidebar();
400+
}
401+
self.firstApp = self.checkIfFirst();
402+
setTimeout(function() {
403+
self.selectedSearchBar = data._id + "";
404+
}, 1);
399405
}
400-
self.firstApp = self.checkIfFirst();
401-
setTimeout(function() {
402-
self.selectedSearchBar = data._id + "";
403-
}, 1);
404406
},
405407
error: function(xhr, status, error) {
406408
CountlyHelpers.notify({

frontend/express/public/javascripts/countly/countly.template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ var AppRouter = Backbone.Router.extend({
14141414
* <span>{{#limitString value 15}}{{/limitString}}</span>
14151415
*/
14161416
Handlebars.registerHelper('limitString', function(string, limit) {
1417-
if (string.length > limit) {
1417+
if (string && string.length > limit) {
14181418
return (string || '').substr(0, limit) + "..";
14191419
}
14201420
else {

frontend/express/public/javascripts/countly/vue/components/drawer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@
127127
* Delete the hover key as its set by the data table on hovering a row
128128
* and we don't want to pass it to the drawer.
129129
*/
130-
delete initialEditedObject.hover;
130+
if (initialEditedObject && initialEditedObject.hover !== undefined) {
131+
delete initialEditedObject.hover;
132+
}
131133
this.drawers[name].initialEditedObject = initialEditedObject || {};
132134
},
133135
closeDrawer: function(name) {

frontend/express/public/localization/dashboard/dashboard.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ common.in-last-weeks-plural = in the last {0} weeks
293293
common.in-last-weeks = in the last week
294294
common.in-last-months-plural = in the last {0} months
295295
common.in-last-months = in the last month
296+
common.in-last-years-plural = in the last {0} years
297+
common.in-last-years = in the last year
296298
common.time-period-select.custom-range = Custom range
297299
common.time-period-select.presets = Presets
298300
common.time-period-select.last-n = In the last

0 commit comments

Comments
 (0)