From 353639e1680f6b7e2883bd915c1b418caae038a2 Mon Sep 17 00:00:00 2001 From: Prasoon Dwivedi Date: Sat, 23 May 2020 23:21:43 +0530 Subject: [PATCH] Use GroupsSummary to create and copy campaign (#1838) The Groups (get all groups and associated targets) call is used while loading the modal for creating and copying a campaign. As the Groups API gets all the associated targets for a groups as well, it slows the system considerably if there are large number of groups and targets (~200 groups each with ~100-10000 targets). As targets are not really needed in this workflow, this call can be replaced by the GroupsSummary call. --- static/js/src/app/campaigns.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/static/js/src/app/campaigns.js b/static/js/src/app/campaigns.js index 17f35733..ee178dd4 100644 --- a/static/js/src/app/campaigns.js +++ b/static/js/src/app/campaigns.js @@ -162,15 +162,16 @@ function deleteCampaign(idx) { } function setupOptions() { - api.groups.get() - .success(function (groups) { + api.groups.summary() + .success(function (summaries) { + groups = summaries.groups if (groups.length == 0) { modalError("No groups found!") return false; } else { var group_s2 = $.map(groups, function (obj) { obj.text = obj.name - obj.title = obj.targets.length + " targets" + obj.title = obj.num_targets + " targets" return obj }); console.log(group_s2)