@@ -789,13 +789,18 @@ plugins.setConfigs("crashes", {
789
789
else if ( params . qstring . list ) {
790
790
common . db . collection ( 'app_users' + params . app_id ) . estimatedDocumentCount ( function ( errCount , total ) {
791
791
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 , [ ] ) ;
797
803
}
798
- common . returnOutput ( params , res || [ ] ) ;
799
804
} ) ;
800
805
}
801
806
else {
@@ -927,15 +932,15 @@ plugins.setConfigs("crashes", {
927
932
if ( params . qstring . filter !== "crash-hidden" ) {
928
933
filter . is_hidden = { $ne : true } ;
929
934
}
930
- if ( typeof filter . _id === "undefined" ) {
931
- filter . _id = { $ne : "meta" } ;
932
- }
935
+
933
936
plugins . dispatch ( "/drill/preprocess_query" , {
934
937
query : filter
935
938
} ) ;
939
+
936
940
common . db . collection ( 'app_crashgroups' + params . app_id ) . estimatedDocumentCount ( function ( crashGroupsErr , total ) {
937
941
total -- ;
938
942
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
+
939
944
cursor . count ( function ( errCursor , count ) {
940
945
if ( params . qstring . iDisplayStart && params . qstring . iDisplayStart !== 0 ) {
941
946
cursor . skip ( parseInt ( params . qstring . iDisplayStart ) ) ;
@@ -949,17 +954,27 @@ plugins.setConfigs("crashes", {
949
954
cursor . sort ( obj ) ;
950
955
}
951
956
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 ) {
956
970
trace . postprocessCrash ( crash ) ;
957
971
delete crash . threads ;
958
972
delete crash . oldthreads ;
959
973
delete crash . olderror ;
974
+ return crash ;
960
975
} ) ;
961
976
}
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 } ) ;
963
978
} ) ;
964
979
} ) ;
965
980
} ) ;
@@ -1533,6 +1548,7 @@ plugins.setConfigs("crashes", {
1533
1548
common . db . collection ( 'app_crashgroups' + appId ) . ensureIndex ( { "lastTs" : 1 } , { background : true } , function ( ) { } ) ;
1534
1549
common . db . collection ( 'app_crashgroups' + appId ) . ensureIndex ( { "latest_version" : 1 } , { background : true } , function ( ) { } ) ;
1535
1550
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 ( ) { } ) ;
1536
1552
common . db . collection ( 'app_crashusers' + appId ) . ensureIndex ( { "group" : 1 , "uid" : 1 } , { background : true } , function ( ) { } ) ;
1537
1553
common . db . collection ( 'app_crashusers' + appId ) . ensureIndex ( { "group" : 1 , "crashes" : 1 , "fatal" : 1 } , { sparse : true , background : true } , function ( ) { } ) ;
1538
1554
common . db . collection ( 'app_crashusers' + appId ) . ensureIndex ( { "uid" : 1 } , { background : true } , function ( ) { } ) ;
@@ -1584,6 +1600,7 @@ plugins.setConfigs("crashes", {
1584
1600
common . db . collection ( 'app_crashgroups' + appId ) . ensureIndex ( { "lastTs" : 1 } , { background : true } , function ( ) { } ) ;
1585
1601
common . db . collection ( 'app_crashgroups' + appId ) . ensureIndex ( { "latest_version" : 1 } , { background : true } , function ( ) { } ) ;
1586
1602
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 ( ) { } ) ;
1587
1604
} ) ;
1588
1605
common . db . collection ( 'crash_share' ) . remove ( { 'app_id' : appId } , function ( ) { } ) ;
1589
1606
common . db . collection ( 'crashdata' ) . remove ( { '_id' : { $regex : appId + ".*" } } , function ( ) { } ) ;
@@ -1613,6 +1630,7 @@ plugins.setConfigs("crashes", {
1613
1630
common . db . collection ( 'app_crashgroups' + appId ) . ensureIndex ( { "lastTs" : 1 } , { background : true } , function ( ) { } ) ;
1614
1631
common . db . collection ( 'app_crashgroups' + appId ) . ensureIndex ( { "latest_version" : 1 } , { background : true } , function ( ) { } ) ;
1615
1632
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 ( ) { } ) ;
1616
1634
} ) ;
1617
1635
common . db . collection ( 'crash_share' ) . remove ( { 'app_id' : appId } , function ( ) { } ) ;
1618
1636
common . db . collection ( 'crashdata' ) . remove ( { '_id' : { $regex : appId + ".*" } } , function ( ) { } ) ;
0 commit comments