Skip to content

Commit 3f7d0f2

Browse files
authored
Merge branch 'next' into SER-1635-alert-testing-edit-columns-icon-is-missing-on-alert-home-page
2 parents 8d81974 + 18e2151 commit 3f7d0f2

File tree

21 files changed

+149
-114
lines changed

21 files changed

+149
-114
lines changed

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,

bin/scripts/data-cleanup/delete_old_views.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ Promise.all([pluginManager.dbConnection("countly"), pluginManager.dbConnection("
9090
let view = await cursor.next();
9191
//Find one drill entry for the view with timestamp greater than expiration date
9292
var drillEntry = await drillSession.client.db("countly_drill").collection(collectionName).findOne({"sg.name": view.view, "ts": { $gt: expiration_timestamp }}, {ts: 1});
93+
var drillEntry2 = await drillSession.client.db("countly_drill").collection("drill_events").findOne({"a": app._id + "", "e": event, "sg.name": view.view, "ts": { $gt: expiration_timestamp }}, {ts: 1});
9394
//If no entry found, delete the view
94-
if (!drillEntry) {
95+
if (!drillEntry && !drillEntry2) {
9596
console.log("Deleting view: ", view.view);
9697
if (!DRY_RUN) {
9798
await new Promise(function(resolve) {

bin/scripts/data-cleanup/remove_old_crashes_sync.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ Promise.all(
6767
count = await drillDb.collection("drill_events" + crypto.createHash('sha1').update("[CLY]_crash" + app._id).digest('hex')).countDocuments({ ts: { $lt: lastUnixTimestamp * 1000 } });
6868
console.log("", count, "drill crashes to be deleted via command");
6969
console.log("", "", "", `db.drill_events${crypto.createHash('sha1').update("[CLY]_crash" + app._id).digest('hex')}.deleteMany({ ts: { $lt: ${lastUnixTimestamp * 1000} } })`);
70+
var count2 = await drillDb.collection("drill_events").countDocuments({"a": app._id + "", "e": "[CLY]_crash", ts: { $lt: lastUnixTimestamp * 1000 } });
71+
console.log("", count2, "drill crashes to be deleted via command");
72+
console.log("", "", "", `db.drill_events.deleteMany({"a": ${app._id}, "e": "[CLY]_crash", ts: { $lt: ${lastUnixTimestamp * 1000} } })`);
7073
checkThreshold(count);
7174
}
7275
else {
@@ -77,8 +80,12 @@ Promise.all(
7780
res = await db.collection(`app_crashes${app._id}`).deleteMany({ ts: { $lt: lastUnixTimestamp } });
7881
console.log("", res, "crashes deleted");
7982
await sleep(SLEEP);
83+
//deleting from old collection
8084
res = await drillDb.collection("drill_events" + crypto.createHash('sha1').update("[CLY]_crash" + app._id).digest('hex')).deleteMany({ ts: { $lt: lastUnixTimestamp * 1000 } });
8185
console.log("", res, "drill crashes deleted");
86+
//deleting from amerged drill collection
87+
res = await drillDb.collection("drill_events").deleteMany({"a": app._id + "", "e": "[CLY]_crash", ts: { $lt: lastUnixTimestamp * 1000 } });
88+
console.log("", res, "drill crashes deleted");
8289
await sleep(SLEEP);
8390
}
8491
}

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/core/user-activity/javascripts/countly.views.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,14 @@
146146

147147
var getUserLoyaltyView = function() {
148148
var tabsVuex = countlyVue.container.tabsVuex(["/analytics/loyalty"]);
149+
var templates = [];
150+
if (countlyGlobal.plugins.indexOf("drill") !== -1) {
151+
templates.push("/drill/templates/query.builder.v2.html");
152+
}
149153
return new countlyVue.views.BackboneWrapper({
150154
component: UserLoyaltyView,
151155
vuex: tabsVuex,
152-
templates: [
153-
"/drill/templates/query.builder.v2.html"
154-
]
156+
templates: templates
155157
});
156158
};
157159

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) {

0 commit comments

Comments
 (0)