Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBS-13872: Show primary alias in user tags and ratings #3432

Merged
merged 3 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/MusicBrainz/Server/Controller/Artist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/MusicBrainz/Server/Controller/Root.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion lib/MusicBrainz/Server/Controller/Tag.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
19 changes: 15 additions & 4 deletions lib/MusicBrainz/Server/Controller/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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',
Expand Down
6 changes: 5 additions & 1 deletion lib/MusicBrainz/Server/Data/Editor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
};
Expand Down