Skip to content

Commit 695066b

Browse files
committed
[export] fix user data export
1 parent acfb952 commit 695066b

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

api/parts/mgmt/app_users.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ usersApi.update = function(app_id, query, update, params, callback) {
108108
callback = params;
109109
params = {};
110110
}
111+
plugins.dispatch("/drill/preprocess_query", {
112+
query: query
113+
});
111114
if (Object.keys(update).length) {
112115
for (var i in update) {
113116
if (i.indexOf("$") !== 0) {
@@ -152,6 +155,9 @@ usersApi.delete = function(app_id, query, params, callback) {
152155
callback = params;
153156
params = {};
154157
}
158+
plugins.dispatch("/drill/preprocess_query", {
159+
query: query
160+
});
155161
common.db.collection("app_users" + app_id).aggregate([
156162
{$match: query},
157163
{
@@ -238,6 +244,10 @@ usersApi.search = function(app_id, query, project, sort, limit, skip, callback)
238244
}
239245
}
240246

247+
plugins.dispatch("/drill/preprocess_query", {
248+
query: query
249+
});
250+
241251
project = project || {};
242252
if (typeof project === "string" && project.length) {
243253
try {
@@ -294,6 +304,10 @@ usersApi.count = function(app_id, query, callback) {
294304
}
295305
}
296306

307+
plugins.dispatch("/drill/preprocess_query", {
308+
query: query
309+
});
310+
297311
common.db.collection('app_users' + app_id).find(query).count(callback);
298312
};
299313

@@ -704,6 +718,11 @@ usersApi.export = function(app_id, query, params, callback) {
704718
}
705719
});
706720
}
721+
722+
plugins.dispatch("/drill/preprocess_query", {
723+
query: query
724+
});
725+
707726
common.db.collection("app_users" + app_id).aggregate([
708727
{$match: query},
709728
{
@@ -817,10 +836,10 @@ usersApi.export = function(app_id, query, params, callback) {
817836
}
818837
}).then(function() {
819838
//export data from metric_changes
820-
return run_command('mongoexport', [...dbargs, "--collection", "metric_changes" + app_id, "-q", '{uid:{$in: ["' + res[0].uid.join('","') + '"]}}', "--out", export_folder + "/metric_changes" + app_id + ".json"]);
839+
return run_command('mongoexport', [...dbargs, "--collection", "metric_changes" + app_id, "-q", '{"uid":{"$in": ["' + res[0].uid.join('","') + '"]}}', "--out", export_folder + "/metric_changes" + app_id + ".json"]);
821840
}).then(function() {
822841
//export data from app_users
823-
return run_command('mongoexport', [...dbargs, "--collection", "app_users" + app_id, "-q", '{uid:{$in: ["' + res[0].uid.join('","') + '"]}}', "--out", export_folder + "/app_users" + app_id + ".json"]);
842+
return run_command('mongoexport', [...dbargs, "--collection", "app_users" + app_id, "-q", '{"uid":{"$in": ["' + res[0].uid.join('","') + '"]}}', "--out", export_folder + "/app_users" + app_id + ".json"]);
824843
}).then(
825844
function() {
826845
//get other export commands from other plugins

plugins/crashes/api/api.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ plugins.setConfigs("crashes", {
8787
if (!ob.export_commands.crashes) {
8888
ob.export_commands.crashes = [];
8989
}
90-
ob.export_commands.crashes.push({cmd: 'mongoexport', args: [...ob.dbargs, '--collection', 'app_crashes' + ob.app_id, '-q', '{uid:{$in: ["' + uids.join('","') + '"]}}', '--out', ob.export_folder + '/crashes' + ob.app_id + '.json']});
91-
ob.export_commands.crashes.push({cmd: 'mongoexport', args: [...ob.dbargs, '--collection', 'app_crashusers' + ob.app_id, '-q', '{uid:{$in: ["' + uids.join('","') + '"]}}', '--out', ob.export_folder + '/crashusers' + ob.app_id + '.json']});
90+
ob.export_commands.crashes.push({cmd: 'mongoexport', args: [...ob.dbargs, '--collection', 'app_crashes' + ob.app_id, '-q', '{"uid":{"$in": ["' + uids.join('","') + '"]}}', '--out', ob.export_folder + '/crashes' + ob.app_id + '.json']});
91+
ob.export_commands.crashes.push({cmd: 'mongoexport', args: [...ob.dbargs, '--collection', 'app_crashusers' + ob.app_id, '-q', '{"uid":{"$in": ["' + uids.join('","') + '"]}}', '--out', ob.export_folder + '/crashusers' + ob.app_id + '.json']});
9292
resolve();
9393
}
9494
});

plugins/push/api/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ const PUSH_CACHE_GROUP = 'P';
576576
plugins.register('/i/app_users/export', ({app_id, uids, export_commands, dbargs, export_folder}) => {
577577
if (uids && uids.length) {
578578
if (!export_commands.push) {
579-
export_commands.push = [{cmd: 'mongoexport', args: [...dbargs, '--collection', `push_${app_id}`, '-q', `{uid: {$in: ${JSON.stringify(uids)}}}`, '--out', `${export_folder}/push_${app_id}.json`]}];
579+
export_commands.push = [{cmd: 'mongoexport', args: [...dbargs, '--collection', `push_${app_id}`, '-q', `{"uid": {"$in": ${JSON.stringify(uids)}}}`, '--out', `${export_folder}/push_${app_id}.json`]}];
580580
}
581581
}
582582
});

plugins/star-rating/api/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ const widgetPropertyPreprocessors = {
784784
if (!ob.export_commands.feedback) {
785785
ob.export_commands.feedback = [];
786786
}
787-
ob.export_commands.feedback.push({cmd: 'mongoexport', args: [...ob.dbargs, '--collection', 'feedback' + ob.app_id, '-q', '{uid:{$in: ["' + uids.join('","') + '"]}}', '--out', ob.export_folder + '/feedback' + ob.app_id + '.json']});
787+
ob.export_commands.feedback.push({cmd: 'mongoexport', args: [...ob.dbargs, '--collection', 'feedback' + ob.app_id, '-q', '{"uid":{"$in": ["' + uids.join('","') + '"]}}', '--out', ob.export_folder + '/feedback' + ob.app_id + '.json']});
788788
resolve();
789789
}
790790
});

plugins/views/api/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ const escapedViewSegments = { "name": true, "segment": true, "height": true, "wi
212212
if (!ob.export_commands.views) {
213213
ob.export_commands.views = [];
214214
}
215-
ob.export_commands.views.push({cmd: 'mongoexport', args: [...ob.dbargs, '--collection', 'app_userviews' + ob.app_id, '-q', '{_id:{$in: ["' + uids.join('","') + '"]}}', '--out', ob.export_folder + '/app_userviews' + ob.app_id + '.json']});
215+
ob.export_commands.views.push({cmd: 'mongoexport', args: [...ob.dbargs, '--collection', 'app_userviews' + ob.app_id, '-q', '{"_id":{"$in": ["' + uids.join('","') + '"]}}', '--out', ob.export_folder + '/app_userviews' + ob.app_id + '.json']});
216216
resolve();
217217
});
218218
});

0 commit comments

Comments
 (0)