Skip to content

Commit 57afb6d

Browse files
authored
Merge pull request #2956 from Countly/crashes-remove-meta
Crashes remove meta
2 parents b645743 + 5cdde1a commit 57afb6d

File tree

3 files changed

+34
-15
lines changed

3 files changed

+34
-15
lines changed

plugins/crashes/api/api.js

+32-14
Original file line numberDiff line numberDiff line change
@@ -789,13 +789,18 @@ plugins.setConfigs("crashes", {
789789
else if (params.qstring.list) {
790790
common.db.collection('app_users' + params.app_id).estimatedDocumentCount(function(errCount, total) {
791791
if (!errCount && total && total < 10000) {
792-
common.db.collection('app_crashgroups' + params.app_id).find({_id: {$ne: "meta"}}, {name: 1}).toArray(function(err, res) {
793-
if (res) {
794-
for (var i = 0; i < res.length; i++) {
795-
res[i].name = (res[i].name + "").split("\n")[0].trim();
796-
}
792+
common.db.collection('app_crashgroups' + params.app_id).find({}, {name: 1}).toArray(function(err, crashes) {
793+
if (crashes) {
794+
const crashData = crashes.filter(crash => crash._id !== 'meta').map(crash => ({
795+
_id: crash._id,
796+
name: (crash.name + "").split("\n")[0].trim(),
797+
}));
798+
799+
common.returnOutput(params, crashData || []);
800+
}
801+
else {
802+
common.returnOutput(params, []);
797803
}
798-
common.returnOutput(params, res || []);
799804
});
800805
}
801806
else {
@@ -927,15 +932,15 @@ plugins.setConfigs("crashes", {
927932
if (params.qstring.filter !== "crash-hidden") {
928933
filter.is_hidden = {$ne: true};
929934
}
930-
if (typeof filter._id === "undefined") {
931-
filter._id = {$ne: "meta"};
932-
}
935+
933936
plugins.dispatch("/drill/preprocess_query", {
934937
query: filter
935938
});
939+
936940
common.db.collection('app_crashgroups' + params.app_id).estimatedDocumentCount(function(crashGroupsErr, total) {
937941
total--;
938942
var cursor = common.db.collection('app_crashgroups' + params.app_id).find(filter, {uid: 1, is_new: 1, is_renewed: 1, is_hidden: 1, os: 1, not_os_specific: 1, name: 1, error: 1, users: 1, lastTs: 1, reports: 1, latest_version: 1, is_resolved: 1, resolved_version: 1, nonfatal: 1, session: 1, is_resolving: 1, native_cpp: 1, plcrash: 1});
943+
939944
cursor.count(function(errCursor, count) {
940945
if (params.qstring.iDisplayStart && params.qstring.iDisplayStart !== 0) {
941946
cursor.skip(parseInt(params.qstring.iDisplayStart));
@@ -949,17 +954,27 @@ plugins.setConfigs("crashes", {
949954
cursor.sort(obj);
950955
}
951956

952-
cursor.toArray(function(cursorErr, res) {
953-
res = res || [];
954-
if (res && res.length) {
955-
res.forEach(function(crash) {
957+
cursor.toArray(function(cursorErr, crashes) {
958+
let crashData = crashes || [];
959+
if (crashes && crashes.length) {
960+
crashData = crashes.filter(function(crash) {
961+
if (crash._id === 'meta') {
962+
total--;
963+
count--;
964+
return false;
965+
}
966+
else {
967+
return true;
968+
}
969+
}).map(function(crash) {
956970
trace.postprocessCrash(crash);
957971
delete crash.threads;
958972
delete crash.oldthreads;
959973
delete crash.olderror;
974+
return crash;
960975
});
961976
}
962-
common.returnOutput(params, {sEcho: params.qstring.sEcho, iTotalRecords: Math.max(total, 0), iTotalDisplayRecords: count, aaData: res});
977+
common.returnOutput(params, {sEcho: params.qstring.sEcho, iTotalRecords: Math.max(total, count, 0), iTotalDisplayRecords: count, aaData: crashData});
963978
});
964979
});
965980
});
@@ -1533,6 +1548,7 @@ plugins.setConfigs("crashes", {
15331548
common.db.collection('app_crashgroups' + appId).ensureIndex({"lastTs": 1}, {background: true}, function() {});
15341549
common.db.collection('app_crashgroups' + appId).ensureIndex({"latest_version": 1}, {background: true}, function() {});
15351550
common.db.collection('app_crashgroups' + appId).ensureIndex({"groups": 1}, {background: true}, function() {});
1551+
common.db.collection('app_crashgroups' + appId).ensureIndex({"is_hidden": 1}, {background: true}, function() {});
15361552
common.db.collection('app_crashusers' + appId).ensureIndex({"group": 1, "uid": 1}, {background: true}, function() {});
15371553
common.db.collection('app_crashusers' + appId).ensureIndex({"group": 1, "crashes": 1, "fatal": 1}, {sparse: true, background: true}, function() {});
15381554
common.db.collection('app_crashusers' + appId).ensureIndex({"uid": 1}, {background: true}, function() {});
@@ -1584,6 +1600,7 @@ plugins.setConfigs("crashes", {
15841600
common.db.collection('app_crashgroups' + appId).ensureIndex({"lastTs": 1}, {background: true}, function() {});
15851601
common.db.collection('app_crashgroups' + appId).ensureIndex({"latest_version": 1}, {background: true}, function() {});
15861602
common.db.collection('app_crashgroups' + appId).ensureIndex({"groups": 1}, {background: true}, function() {});
1603+
common.db.collection('app_crashgroups' + appId).ensureIndex({"is_hidden": 1}, {background: true}, function() {});
15871604
});
15881605
common.db.collection('crash_share').remove({'app_id': appId }, function() {});
15891606
common.db.collection('crashdata').remove({'_id': {$regex: appId + ".*"}}, function() {});
@@ -1613,6 +1630,7 @@ plugins.setConfigs("crashes", {
16131630
common.db.collection('app_crashgroups' + appId).ensureIndex({"lastTs": 1}, {background: true}, function() {});
16141631
common.db.collection('app_crashgroups' + appId).ensureIndex({"latest_version": 1}, {background: true}, function() {});
16151632
common.db.collection('app_crashgroups' + appId).ensureIndex({"groups": 1}, {background: true}, function() {});
1633+
common.db.collection('app_crashgroups' + appId).ensureIndex({"is_hidden": 1}, {background: true}, function() {});
16161634
});
16171635
common.db.collection('crash_share').remove({'app_id': appId }, function() {});
16181636
common.db.collection('crashdata').remove({'_id': {$regex: appId + ".*"}}, function() {});

plugins/crashes/frontend/public/javascripts/countly.views.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ window.CrashesView = countlyView.extend({
979979

980980
$("#crash-" + self.curMetric).parents(".big-numbers").addClass("active");
981981

982-
self.dtable.fnDraw(false);
982+
self.dtable && self.dtable.fnDraw(false);
983983

984984
self.pageScripts();
985985
countlyCommon.drawTimeGraph(chartData.chartDP, "#dashboard-graph");

plugins/crashes/install.js

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pluginManager.dbConnection().then((countlyDb) => {
2727
countlyDb.collection('app_crashgroups' + app._id).ensureIndex({"lastTs": 1}, {background: true}, cb);
2828
countlyDb.collection('app_crashgroups' + app._id).ensureIndex({"latest_version": 1}, {background: true}, cb);
2929
countlyDb.collection('app_crashgroups' + app._id).ensureIndex({"groups": 1}, {background: true}, cb);
30+
countlyDb.collection('app_crashgroups' + app._id).ensureIndex({"is_hidden": 1}, {background: true}, cb);
3031
countlyDb.collection('app_crashusers' + app._id).ensureIndex({"group": 1, "uid": 1}, {background: true}, cb);
3132
countlyDb.collection('app_crashusers' + app._id).ensureIndex({"group": 1, "crashes": 1, "fatal": 1}, {sparse: true, background: true}, cb);
3233
countlyDb.collection('app_crashusers' + app._id).ensureIndex({"uid": 1}, {background: true}, cb);

0 commit comments

Comments
 (0)