6
6
*/
7
7
8
8
9
- const { ObjectId } = require ( 'mongodb' ) ;
10
9
const pluginManager = require ( '../../../plugins/pluginManager.js' ) ;
11
10
const common = require ( '../../../api/utils/common.js' ) ;
12
11
const drillCommon = require ( '../../../plugins/drill/api/common.js' ) ;
@@ -25,7 +24,7 @@ Promise.all([pluginManager.dbConnection("countly"), pluginManager.dbConnection("
25
24
26
25
//GET APP
27
26
try {
28
- const app = await countlyDb . collection ( "apps" ) . findOne ( { _id : ObjectId ( APP_ID ) } , { _id : 1 , name : 1 } ) ;
27
+ const app = await countlyDb . collection ( "apps" ) . findOne ( { _id : countlyDb . ObjectID ( APP_ID ) } , { _id : 1 , name : 1 } ) ;
29
28
console . log ( "App:" , app . name ) ;
30
29
//GET EVENTS
31
30
var events = [ ] ;
@@ -51,6 +50,27 @@ Promise.all([pluginManager.dbConnection("countly"), pluginManager.dbConnection("
51
50
}
52
51
] ) . toArray ( ) ;
53
52
events = events . length ? events [ 0 ] . list : [ ] ;
53
+ const metaEvents = await drillDb . collection ( "drill_meta" ) . aggregate ( [
54
+ {
55
+ $match : {
56
+ 'app_id' : app . _id + "" ,
57
+ "type" : "e" ,
58
+ "e" : { $regex : regex , $options : CASE_INSENSITIVE ? "i" : "" , $nin : events }
59
+ }
60
+ } ,
61
+ {
62
+ $group : {
63
+ _id : "$e"
64
+ }
65
+ } ,
66
+ {
67
+ $project : {
68
+ _id : 0 ,
69
+ e : "$_id"
70
+ }
71
+ }
72
+ ] ) . toArray ( ) ;
73
+ events = events . concat ( metaEvents . map ( e => e . e ) ) ;
54
74
}
55
75
catch ( err ) {
56
76
close ( "Invalid regex" ) ;
@@ -86,6 +106,7 @@ Promise.all([pluginManager.dbConnection("countly"), pluginManager.dbConnection("
86
106
close ( err ) ;
87
107
}
88
108
109
+
89
110
async function deleteDrillEvents ( appId , events ) {
90
111
for ( let i = 0 ; i < events . length ; i ++ ) {
91
112
var collectionName = drillCommon . getCollectionName ( events [ i ] , appId ) ;
0 commit comments