Skip to content

Commit

Permalink
Merge pull request #691 from zlamalp/insight
Browse files Browse the repository at this point in the history
feat(insight_mu): sort json output to be comparable
  • Loading branch information
zlamalp authored May 25, 2022
2 parents 077b4fa + 343194f commit 0c3132f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions gen/insight_mu
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use POSIX qw(strftime);

our $SERVICE_NAME = "insight_mu";
our $PROTOCOL_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.1";
my $SCRIPT_VERSION = "3.0.2";

perunServicesInit::init;
my $DIRECTORY = perunServicesInit::getDirectory;
Expand Down Expand Up @@ -80,7 +80,7 @@ foreach my $resourceId ($data->getResourceIds()) {
};
$memberDataById->{$uco} = $person;
}
my @membersList = keys %members;
my @membersList = sort { $a <=> $b } keys %members;
# decide whether group or workplace depending on defined VAZPR attribute
unless ( defined $groupVAZPR ) {
my $group = {
Expand Down Expand Up @@ -117,6 +117,14 @@ my @groupValues = values(%$groupDataById);
my @workplaceValues = values(%$workplaceDataById);
my @personValues = values(%$memberDataById);

# sort persons by UCO
@personValues = sort { $a->{'UCO'} <=> $b->{'UCO'} } @personValues;
# sort groups by externalObjectId = Group ID
@groupValues = sort { $a->{'ExternalObjectID'} <=> $b->{'ExternalObjectID'} } @groupValues;
# sort workplaces by externalObjectId = Group ID
@workplaceValues = sort { $a->{'ExternalObjectID'} <=> $b->{'ExternalObjectID'} } @workplaceValues;


# get data in desired format
my $groupData = {
data => {Contact => [{Group => [{PerunGroup => \@groupValues}]}]}
Expand Down

0 comments on commit 0c3132f

Please sign in to comment.