Skip to content

Commit 98e68c9

Browse files
committed
Merge branch 'production'
* production: MBS-11472: Do partition_by before converting attribute to JSON MBS-11486: Load release info in NoLanguage before JSON conversion
2 parents 80719d5 + 4b63583 commit 98e68c9

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

lib/MusicBrainz/Server/Edit/Work.pm

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use List::UtilsBy qw( partition_by );
33
use Moose::Role;
44
use namespace::autoclean;
55

6-
use MusicBrainz::Server::Entity::Util::JSON qw( to_json_object );
6+
use MusicBrainz::Server::Entity::Util::JSON qw( to_json_array );
77
use MusicBrainz::Server::Translation 'l';
88

99
sub edit_category { l('Work') }
@@ -21,16 +21,21 @@ sub grouped_attributes_by_type {
2121
grep { $_ } map { $_->{attribute_value_id} } @$attributes
2222
);
2323

24-
return partition_by { $_->type->l_name } map {
25-
my $attr = MusicBrainz::Server::Entity::WorkAttribute->new(
24+
my %partitioned_attributes = partition_by { $_->type->l_name } map {
25+
MusicBrainz::Server::Entity::WorkAttribute->new(
2626
id => $_->{id},
2727
type_id => $_->{attribute_type_id},
2828
type => $attribute_types->{$_->{attribute_type_id}},
2929
value => $_->{attribute_text} // $attribute_values->{$_->{attribute_value_id}}->value,
3030
value_id => $_->{attribute_value_id}
3131
);
32-
$to_json ? to_json_object($attr) : $attr;
3332
} @$attributes;
33+
34+
if ($to_json) {
35+
%partitioned_attributes = map { $_ => to_json_array($partitioned_attributes{$_}) } keys %partitioned_attributes;
36+
}
37+
38+
return %partitioned_attributes;
3439
}
3540

3641
1;

lib/MusicBrainz/Server/Report/NoLanguage.pm

+4-8
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ use Moose;
44
with 'MusicBrainz::Server::Report::ReleaseReport',
55
'MusicBrainz::Server::Report::FilterForEditor::ReleaseID';
66

7-
around inflate_rows => sub {
8-
my $orig = shift;
9-
my $self = shift;
7+
after _load_extra_release_info => sub {
8+
my ($self, @releases) = @_;
109

11-
my $rows = $self->$orig(@_);
12-
$self->c->model('Language')->load(map { $_->{release} } @$rows);
13-
$self->c->model('Script')->load(map { $_->{release} } @$rows);
14-
15-
return $rows;
10+
$self->c->model('Language')->load(@releases);
11+
$self->c->model('Script')->load(@releases);
1612
};
1713

1814
sub query {

0 commit comments

Comments
 (0)