Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions bin/scripts/expire-data/delete_custom_events_regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/


const { ObjectId } = require('mongodb');
const pluginManager = require('../../../plugins/pluginManager.js');
const common = require('../../../api/utils/common.js');
const drillCommon = require('../../../plugins/drill/api/common.js');
Expand All @@ -25,7 +24,7 @@ Promise.all([pluginManager.dbConnection("countly"), pluginManager.dbConnection("

//GET APP
try {
const app = await countlyDb.collection("apps").findOne({_id: ObjectId(APP_ID)}, {_id: 1, name: 1});
const app = await countlyDb.collection("apps").findOne({_id: countlyDb.ObjectID(APP_ID)}, {_id: 1, name: 1});
console.log("App:", app.name);
//GET EVENTS
var events = [];
Expand All @@ -51,6 +50,15 @@ Promise.all([pluginManager.dbConnection("countly"), pluginManager.dbConnection("
}
]).toArray();
events = events.length ? events[0].list : [];
var metaEvents = await drillDb.collection("drill_meta").find(
{
'app_id': app._id + "",
"type": "e",
"e": {$regex: regex, $options: CASE_INSENSITIVE ? "i" : "", $nin: events}
},
{ _id: 0, e: 1}
).toArray();
events = events.concat(metaEvents.map(e => e.e));
}
catch (err) {
close("Invalid regex");
Expand Down Expand Up @@ -86,6 +94,7 @@ Promise.all([pluginManager.dbConnection("countly"), pluginManager.dbConnection("
close(err);
}


async function deleteDrillEvents(appId, events) {
for (let i = 0; i < events.length; i++) {
var collectionName = drillCommon.getCollectionName(events[i], appId);
Expand Down
Loading