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.
pull/1791/head
Prasoon Dwivedi 2020-05-23 23:21:43 +05:30 committed by GitHub
parent 726e3c96ac
commit 353639e168
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -162,15 +162,16 @@ function deleteCampaign(idx) {
} }
function setupOptions() { function setupOptions() {
api.groups.get() api.groups.summary()
.success(function (groups) { .success(function (summaries) {
groups = summaries.groups
if (groups.length == 0) { if (groups.length == 0) {
modalError("No groups found!") modalError("No groups found!")
return false; return false;
} else { } else {
var group_s2 = $.map(groups, function (obj) { var group_s2 = $.map(groups, function (obj) {
obj.text = obj.name obj.text = obj.name
obj.title = obj.targets.length + " targets" obj.title = obj.num_targets + " targets"
return obj return obj
}); });
console.log(group_s2) console.log(group_s2)