Skip to content

Commit

Permalink
Sort output in export script.
Browse files Browse the repository at this point in the history
Makes it easier to compare.
  • Loading branch information
dracos committed Feb 18, 2021
1 parent b4b77fc commit db42d32
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions bin/export-import-data
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ sub export {
if (@categories) {
my @contacts = $body->contacts->search({
category => { -in => \@categories },
})->all;
})->search(undef, { order_by => 'category' })->all;
die "Categories mismatch" unless scalar @categories == scalar @contacts;
for (@contacts) {
push @{$out{contacts}}, {
Expand All @@ -56,7 +56,7 @@ sub export {
}
}

my $templates = $body->response_templates;
my $templates = $body->response_templates->search(undef, { order_by => 'title' });
if (@categories) {
$templates = $templates->search({
'contact.category' => { -in => \@categories }
Expand All @@ -69,27 +69,27 @@ sub export {
title => $_->title,
text => $_->text,
state => $_->state,
categories => [ map { $_->category } $_->contacts->all ],
categories => [ sort map { $_->category } $_->contacts->all ],
auto_response => $_->auto_response,
external_status_code => $_->external_status_code,
};
}

for ($body->roles->all) {
for ($body->roles->search(undef, { order_by => 'name' })->all) {
push @{$out{roles}}, {
permissions => $_->permissions,
name => $_->name,
};
}

for ($body->users->all) {
for ($body->users->search(undef, { order_by => 'name' })->all) {
my $cats = $_->get_extra_metadata('categories');
my @cat_names = map { $body->contacts->find({id => $_})->category } @$cats;
my @cat_names = sort map { $body->contacts->find({id => $_})->category } @$cats;
push @{$out{users}}, {
email => $_->email,
name => $_->name,
password => $_->password,
roles => [ map { $_->name } $_->roles->all ],
roles => [ sort map { $_->name } $_->roles->all ],
categories => \@cat_names,
areas => $_->area_ids || [],
};
Expand Down

0 comments on commit db42d32

Please sign in to comment.