diff --git a/lib/MusicBrainz/Server/Controller/Artist.pm b/lib/MusicBrainz/Server/Controller/Artist.pm index 62c3641bcd3..607a821dcc5 100644 --- a/lib/MusicBrainz/Server/Controller/Artist.pm +++ b/lib/MusicBrainz/Server/Controller/Artist.pm @@ -726,6 +726,7 @@ sub _merge_load_entities { my ($self, $c, @artists) = @_; $c->model('ArtistType')->load(@artists); + $c->model('Artist')->load_aliases(@artists); $c->model('Gender')->load(@artists); $c->model('Area')->load(@artists); $c->model('Area')->load_containment(map { $_->{area} } @artists); diff --git a/lib/MusicBrainz/Server/Controller/Root.pm b/lib/MusicBrainz/Server/Controller/Root.pm index b2cf62d48f9..cb472406359 100644 --- a/lib/MusicBrainz/Server/Controller/Root.pm +++ b/lib/MusicBrainz/Server/Controller/Root.pm @@ -457,7 +457,7 @@ sub begin : Private my @merge = values %{ $model->get_by_ids($merger->all_entities); }; - $model->load_aliases(@merge) if $model->can('load_aliases'); + $model->load_aliases(@merge) if $entity_properties->{aliases}; $c->model('ArtistCredit')->load(@merge) if $entity_properties->{artist_credits}; diff --git a/lib/MusicBrainz/Server/Controller/Tag.pm b/lib/MusicBrainz/Server/Controller/Tag.pm index 7ad275d9726..9e426fa3cbc 100644 --- a/lib/MusicBrainz/Server/Controller/Tag.pm +++ b/lib/MusicBrainz/Server/Controller/Tag.pm @@ -98,7 +98,7 @@ sub show : Chained('load') PathPart('') my @entities = map { $_->entity } @$entity_tags; $model->load_aliases(@entities) - if $model->can('load_aliases'); + if $entity_properties->{aliases}; $c->model('ArtistCredit')->load(@entities) if $entity_properties->{artist_credits}; diff --git a/lib/MusicBrainz/Server/Controller/User.pm b/lib/MusicBrainz/Server/Controller/User.pm index bfebacc7459..865fda0bc9b 100644 --- a/lib/MusicBrainz/Server/Controller/User.pm +++ b/lib/MusicBrainz/Server/Controller/User.pm @@ -573,6 +573,8 @@ sub ratings : Chained('load') PathPart('ratings') Args(1) HiddenOnMirrors }, limit => 100); $c->model('ArtistCredit')->load(@$ratings) if $entity_properties->{artist_credits}; + $c->model($model)->load_aliases(@$ratings) + if $entity_properties->{aliases}; my %props = ( entityType => $type, @@ -655,11 +657,15 @@ sub tag : Chained('load_tag') PathPart('') if ($tag) { %tagged_entities = map { my $entity_properties = $ENTITIES{$_}; + my $model = $c->model($entity_properties->{model}); - my ($entities, $total) = $c->model($entity_properties->{model})->tags->find_editor_entities( + my ($entities, $total) = $model->tags->find_editor_entities( $user->id, $tag->id, $show_downvoted, 10, 0); - $c->model('ArtistCredit')->load(map { $_->entity } @$entities) + my @entity_entries = map { $_->entity } @$entities; + $c->model('ArtistCredit')->load(@entity_entries) if $entity_properties->{artist_credits}; + $model->load_aliases(@entity_entries) + if $entity_properties->{aliases}; ("$_" => { count => $total, @@ -694,6 +700,7 @@ for my $entity_type (entities_with('tags')) { my $method = sub { my ($self, $c) = @_; + my $model = $c->model($entity_properties->{model}); my $user = $c->stash->{user}; my $tag = $c->stash->{tag}; my $show_downvoted = $c->req->params->{show_downvoted} ? 1 : 0; @@ -708,10 +715,14 @@ for my $entity_type (entities_with('tags')) { my $entity_tags = $self->_load_paged($c, sub { return ([], 0) unless $tag; - return $c->model($entity_properties->{model})->tags->find_editor_entities( + return $model->tags->find_editor_entities( $user->id, $c->stash->{tag}->id, $show_downvoted, shift, shift); }); - $c->model('ArtistCredit')->load(map { $_->entity } @$entity_tags) if $entity_properties->{artist_credits}; + my @entity_entries = map { $_->entity } @$entity_tags; + $c->model('ArtistCredit')->load(@entity_entries) + if $entity_properties->{artist_credits}; + $model->load_aliases(@entity_entries) + if $entity_properties->{aliases}; $c->stash( current_view => 'Node', diff --git a/lib/MusicBrainz/Server/Data/Editor.pm b/lib/MusicBrainz/Server/Data/Editor.pm index 2b0a4fc8b10..d9590c0d4a9 100644 --- a/lib/MusicBrainz/Server/Data/Editor.pm +++ b/lib/MusicBrainz/Server/Data/Editor.pm @@ -122,12 +122,16 @@ sub summarize_ratings return { map { my $entity_properties = $ENTITIES{$_}; - my ($entities) = $self->c->model($entity_properties->{model})->rating + my $model = $self->c->model($entity_properties->{model}); + my ($entities) = $model->rating ->find_editor_ratings($user->id, $me, 10, 0); $self->c->model('ArtistCredit')->load(@$entities) if $entity_properties->{artist_credits}; + $model->load_aliases(@$entities) + if $entity_properties->{aliases}; + ($_ => to_json_array($entities)); } entities_with('ratings'), };