Skip to content

Commit

Permalink
Merge branch 'beta' into production
Browse files Browse the repository at this point in the history
* beta:
  Drop autoselect for Apple Music (#1643)
  Update translations from Transifex
  Revert "MBS-8725: Allow mediums to have an unknown tracklist (#1103)"
  Update POT files using the production database
  Update translations from Transifex
  MBS-7994 / MBS-10746: Add pregap icon and indicate pregap in edits (#1572)
  MBS-10949 (2/2): Add Migu Music URL to the sidebar
  MBS-10949 (1/2): Handle Migu Music URLs
  MBS-10989: Update VocaDB cleanup to support new Es (series) format (#1614)
  MBS-10980: Convert Remove Entity edit to React (#1606)
  MBS-10983: Convert Remove Release Label edit to React (#1609)
  MBS-10193: Support Apple Music and Apple Books (#1597)
  MBS-10974: Convert Remove ISRC edit to React (#1604)
  MBS-10975: Convert Remove ISWC edit to React (#1605)
  MBS-10969: Convert Add ISRCs edit to React (#1600)
  MBS-10970: Convert Add Release Label edit to React (#1601)
  MBS-10968: Convert Add ISWCs edit to React (#1599)
  Install bzip2 in the test-database docker image (#1621)
  MBS-8725: Allow mediums to have an unknown tracklist (#1103)
  Skip looking for latest vote when not logged in (#1607)
  MBS-10923: Fix inconsistent ordering in find_by_collection (#1591)
  Bump lodash version to 4.17.19
  Bump react-table version to 7.3.2
  Fix warning when displaying Add rel. attr. edit
  MBS-10926: Add 'copy date' button on relationship editor dialog (#1583)
  Strengthen the validation of Instagram URLs
  Refactor: Simplify cleanup regexp for Instagram
  MBS-10932: Match Instagram videos /p/ and /tv/
  Fix handling of js tape object serialization
  MBS-10973: Convert Add Relationship Attribute edit to React
  MBS-10930: Fix loading relationship entities for removed reltypes (#1589)
  MBS-10943: Fix loading attribute on Relationship::Delete (#1594)
  Avoid warnings in Entity::Relationship
  MBS-10833: Avoid crashing if entity0_id is missing
  MBS-10917: Remove no longer used "attendance" (#1579)
  MBS-10927: Check whether entity existed before setting allowNew (#1584)
  MBS-10937: Run load_meta on event lists for ratings (#1587)
  Improve upon MBS-9502 with list of releases
  Move help messages about barcode together in the release editor
  MBS-9502: Add search for pre-existing barcode value in release editor
  Bump Flow to 0.129.0
  Fix some left-behind "import React" imports (#1580)
  MBS-10928: Update the VGMdb favicon
  MBS-10925: Update the Baidu Baike favicon
  MBS-10816: Convert Add Label Edit to React (#1506)
  Bump react-table version to 7.2.1 (#1576)
  Add context to translation strings
  MBS-10562: Add phrases for future (sidebar) dates
  • Loading branch information
yvanzo committed Aug 10, 2020
2 parents ed95cc7 + 063d9c9 commit daeabfd
Show file tree
Hide file tree
Showing 111 changed files with 5,821 additions and 3,666 deletions.
10 changes: 6 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ jobs:
NODE_ENV=test WEBPACK_MODE=development sudo -E -H -u musicbrainz carton exec -- ./script/compile_resources.sh server web-tests
sudo -E -H -u musicbrainz ./node_modules/.bin/flow --quiet
rm /etc/service/chrome/down && sv start chrome
export JUNIT_OUTPUT_FILE=junit_output/js.xml
sudo -E -H -u musicbrainz carton exec -- prove \
sudo -E -H -u musicbrainz carton exec -- perl \
-I lib \
t/js.t \
| tee >(./node_modules/.bin/tap-junit > ./junit_output/js.xml) \
| ./node_modules/.bin/tap-difflet
sudo -E -H -u musicbrainz carton exec -- node \
t/web.js \
--harness=TAP::Harness::JUnit \
-v
| tee >(./node_modules/.bin/tap-junit > ./junit_output/js_web.xml) \
| ./node_modules/.bin/tap-difflet
sv kill chrome
./docker/musicbrainz-tests/add_mbtest_alias.sh
sudo -u postgres createdb -O musicbrainz -T musicbrainz_test -U postgres musicbrainz_test_json_dump
Expand Down
2 changes: 1 addition & 1 deletion docker/templates/Dockerfile.test-database.m4
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG DEBIAN_FRONTEND=noninteractive
# install_extensions.sh removes certain build dependencies that we need, so we
# can't install everything here.
# Note: curl is also a dependency of carton.
RUN apt_install(`ca-certificates curl sudo')
RUN apt_install(`bzip2 ca-certificates curl sudo')

RUN cd /tmp && \
curl -O https://raw.githubusercontent.com/metabrainz/docker-postgres/0daa45e/postgres-master/install_extensions.sh && \
Expand Down
1 change: 1 addition & 0 deletions lib/MusicBrainz/Server/Controller/Area.pm
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ sub events : Chained('load')
$c->model('Area')->load(map { $_->{entity} } map { $_->all_places } @$events);
$c->model('Area')->load_containment(map { (map { $_->{entity} } $_->all_areas),
(map { $_->{entity}->area } $_->all_places) } @$events);
$c->model('Event')->load_meta(@$events);
$c->model('Event')->rating->load_user_ratings($c->user->id, @$events) if $c->user_exists;

my %props = (
Expand Down
1 change: 1 addition & 0 deletions lib/MusicBrainz/Server/Controller/Artist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ sub events : Chained('load')
});
$c->model('Event')->load_related_info(@$events);
$c->model('Event')->load_areas(@$events);
$c->model('Event')->load_meta(@$events);
$c->model('Event')->rating->load_user_ratings($c->user->id, @$events) if $c->user_exists;

my %props = (
Expand Down
5 changes: 2 additions & 3 deletions lib/MusicBrainz/Server/Controller/Event.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ with 'MusicBrainz::Server::Controller::Role::WikipediaExtract';
with 'MusicBrainz::Server::Controller::Role::CommonsImage';
with 'MusicBrainz::Server::Controller::Role::EditRelationships';
with 'MusicBrainz::Server::Controller::Role::Collection' => {
entity_type => 'event',
method_name => 'attendance'
entity_type => 'event'
};

use MusicBrainz::Server::Constants qw( $EDIT_EVENT_CREATE $EDIT_EVENT_DELETE $EDIT_EVENT_EDIT $EDIT_EVENT_MERGE );
Expand Down Expand Up @@ -52,7 +51,7 @@ after 'load' => sub {
};

# Stuff that has the side bar and thus needs to display collection information
after [qw( show aliases attendance details tags )] => sub {
after [qw( show aliases collections details tags )] => sub {
my ($self, $c) = @_;
$self->_stash_collections($c);
};
Expand Down
1 change: 1 addition & 0 deletions lib/MusicBrainz/Server/Controller/Place.pm
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ sub events : Chained('load')
$c->model('Event')->find_by_place($c->stash->{place}->id, shift, shift);
});
$c->model('Event')->load_related_info(@$events);
$c->model('Event')->load_meta(@$events);
$c->model('Event')->rating->load_user_ratings($c->user->id, @$events) if $c->user_exists;

my %props = (
Expand Down
5 changes: 4 additions & 1 deletion lib/MusicBrainz/Server/Data/Recording.pm
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ sub _order_by {
},
});

return ($order_by, $extra_join, $also_select)
my $inner_order_by = $order_by
=~ s/ac_name/ac.name/r;

return ($order_by, $extra_join, $also_select, $inner_order_by);
}

sub can_delete {
Expand Down
30 changes: 19 additions & 11 deletions lib/MusicBrainz/Server/Data/Release.pm
Original file line number Diff line number Diff line change
Expand Up @@ -693,10 +693,10 @@ sub _order_by {

my $order_by = order_by($order, "date", {
"date" => sub {
return "date_year, date_month, date_day, name COLLATE musicbrainz"
return "date_year, date_month, date_day, release.name COLLATE musicbrainz"
},
"name" => sub {
return "name COLLATE musicbrainz, date_year, date_month, date_day"
return "release.name COLLATE musicbrainz, date_year, date_month, date_day"
},
"country" => sub {
$extra_join = "LEFT JOIN area ON release_event.country = area.id";
Expand All @@ -706,7 +706,7 @@ sub _order_by {
"artist" => sub {
$extra_join = "JOIN artist_credit ac ON ac.id = release.artist_credit";
$also_select = "ac.name AS ac_name";
return "ac_name COLLATE musicbrainz, name COLLATE musicbrainz";
return "ac_name COLLATE musicbrainz, release.name COLLATE musicbrainz";
},
"label" => sub {
$extra_join = "LEFT OUTER JOIN
Expand All @@ -715,33 +715,33 @@ sub _order_by {
GROUP BY release) rl
ON rl.release = release.id";
$also_select = "rl.labels AS labels";
return "labels, name COLLATE musicbrainz";
return "labels, release.name COLLATE musicbrainz";
},
"catno" => sub {
$extra_join = "LEFT OUTER JOIN
(SELECT release, array_agg(catalog_number) AS catnos from release_label
WHERE catalog_number IS NOT NULL GROUP BY release) rl
ON rl.release = release.id";
$also_select = "catnos";
return "catnos, name COLLATE musicbrainz";
return "catnos, release.name COLLATE musicbrainz";
},
"format" => sub {
$extra_join = "LEFT JOIN medium ON medium.release = release.id
LEFT JOIN medium_format ON medium.format = medium_format.id";
$also_select = "medium_format.name AS medium_format_name";
return "medium_format_name, name COLLATE musicbrainz";
return "medium_format_name COLLATE musicbrainz, release.name COLLATE musicbrainz";
},
"tracks" => sub {
$extra_join = "LEFT JOIN
(SELECT medium.release, sum(track_count) AS total_track_count
FROM medium
GROUP BY medium.release) medium
ON medium.release = release.id";
GROUP BY medium.release) tc
ON tc.release = release.id";
$also_select = "total_track_count";
return "total_track_count, name COLLATE musicbrainz";
return "total_track_count, release.name COLLATE musicbrainz";
},
"barcode" => sub {
return "length(barcode), barcode, name COLLATE musicbrainz"
return "length(barcode), barcode, release.name COLLATE musicbrainz"
},
});

Expand All @@ -753,7 +753,15 @@ sub _order_by {

$extra_join = "LEFT JOIN release_event ON release_event.release = release.id " . $extra_join;

return ($order_by, $extra_join, $also_select);
my $inner_order_by = $order_by
=~ s/country_name/area.name/r
=~ s/ac_name/ac.name/r
=~ s/labels/rl.labels/r
=~ s/catnos/rl.catnos/r
=~ s/medium_format_name/medium_format.name/r
=~ s/total_track_count/tc.total_track_count/r;

return ($order_by, $extra_join, $also_select, $inner_order_by);
}

sub _insert_hook_after_each {
Expand Down
5 changes: 4 additions & 1 deletion lib/MusicBrainz/Server/Data/ReleaseGroup.pm
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@ sub _order_by {
}
});

return ($order_by, $extra_join, $also_select)
my $inner_order_by = $order_by
=~ s/ac_name/ac.name/r;

return ($order_by, $extra_join, $also_select, $inner_order_by);
}

sub _insert_hook_after_each {
Expand Down
7 changes: 4 additions & 3 deletions lib/MusicBrainz/Server/Data/Role/Collection.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ requires '_order_by', '_table', '_type', '_columns', '_new_from_row', 'c';
sub find_by_collection {
my ($self, $collection_id, $limit, $offset, $order) = @_;

my ($order_by, $extra_join, $also_select) = $self->_order_by($order);
my ($order_by, $extra_join, $also_select, $inner_order_by) = $self->_order_by($order);
$extra_join //= '';
$inner_order_by //= $order_by;

my $table = $self->_table;
my $type = $self->_type;
Expand All @@ -22,9 +23,9 @@ sub find_by_collection {
JOIN editor_collection_$type ec ON " . $self->_id_column . " = ec.$type
$extra_join
WHERE ec.collection = ?
ORDER BY id
ORDER BY id, $inner_order_by
) $type
ORDER BY $order_by";
ORDER BY $order_by, id";

$self->query_to_list_limited($query, [$collection_id], $limit, $offset);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/MusicBrainz/Server/Data/URL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ my %URL_SPECIALIZATIONS = (
'Animationsong' => qr{^https?://(?:www\.)?animationsong\.com/}i,
'AnimeNewsNetwork' => qr{^https?://(?:www\.)?animenewsnetwork\.com/}i,
'AnisonGeneration' => qr{^https?://anison\.info/}i,
'AppleBooks' => qr{^https?://books\.apple\.com/}i,
'AppleMusic' => qr{^https?://music\.apple\.com/}i,
'ASIN' => qr{^https?://(?:www\.)?amazon(.*?)(?:\:[0-9]+)?/.*/([0-9B][0-9A-Z]{9})(?:[^0-9A-Z]|$)}i,
'BBCMusic' => qr{^https?://(?:www\.)?bbc\.co\.uk/music/}i,
'BaiduBaike' => qr{^https?://baike\.baidu\.com/}i,
Expand Down Expand Up @@ -104,6 +106,7 @@ my %URL_SPECIALIZATIONS = (
'MainlyNorfolk' => qr{^https?://(?:www\.)?mainlynorfolk\.info/}i,
'Maniadb' => qr{^https?://(?:www\.)?maniadb\.com/}i,
'MetalArchives' => qr{^https?://(?:www\.)?metal-archives\.com/}i,
'MiguMusic' => qr{^https?://music\.migu\.cn/}i,
'Mixcloud' => qr{^https?://(?:www\.)?mixcloud\.com/}i,
'MusicaPopularCl' => qr{^https?://(?:www\.)?musicapopular\.cl/}i,
'MusicMoz' => qr{^https?://(?:www\.)?musicmoz\.org/}i,
Expand Down
2 changes: 1 addition & 1 deletion lib/MusicBrainz/Server/Edit/Generic/Delete.pm
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ override accept => sub {
# We do allow auto edits for this (as ModBot needs to insert them)
sub modbot_auto_edit { 1 }

sub edit_template { "remove_entity" };
sub edit_template_react { 'RemoveEntity' };

__PACKAGE__->meta->make_immutable;

Expand Down
5 changes: 4 additions & 1 deletion lib/MusicBrainz/Server/Edit/Historic/Relationship.pm
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ sub _expand_relationships {
} @$mappings;
}

# To access entities missing an ID via linkedEntities later on
my $fake_entity_id = 1000000000;

sub _display_relationships {
my ($self, $data, $loaded) = @_;
return [
Expand All @@ -216,7 +219,7 @@ sub _display_relationships {
my $entity1_type = $_->{entity1_type};
my $model0 = type_to_model( $_->{entity0_type} );
my $model1 = type_to_model( $_->{entity1_type} );
my $entity0_id = $_->{entity0_id};
my $entity0_id = $_->{entity0_id} // $fake_entity_id++;
my $entity1_id = $_->{entity1_id};
my $entity0 = $loaded->{ $model0 }{ $entity0_id } ||
$self->c->model($model0)->_entity_class->new(
Expand Down
8 changes: 5 additions & 3 deletions lib/MusicBrainz/Server/Edit/Label/Create.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use MooseX::Types::Moose qw( ArrayRef Bool Int Str );
use MooseX::Types::Structured qw( Dict Optional );
use Moose::Util::TypeConstraints qw( subtype find_type_constraint );
use MusicBrainz::Server::Constants qw( $EDIT_LABEL_CREATE );
use MusicBrainz::Server::Data::Utils qw( boolean_to_json );
use MusicBrainz::Server::Edit::Types qw( Nullable PartialDateHash );
use MusicBrainz::Server::Entity::PartialDate;
use MusicBrainz::Server::Entity::Types;
Expand All @@ -28,6 +29,7 @@ sub edit_name { N_l('Add label') }
sub edit_type { $EDIT_LABEL_CREATE }
sub _create_model { 'Label' }
sub label_id { shift->entity_id }
sub edit_template_react { 'AddLabel' }

has '+data' => (
isa => Dict[
Expand Down Expand Up @@ -70,18 +72,18 @@ sub build_display_data
label => ($self->entity_id && $loaded->{Label}{ $self->entity_id })
|| Label->new( name => $self->data->{name} ),
name => $self->data->{name},
sort_name => $self->data->{sort_name},
sort_name => $self->data->{sort_name} // '',
type => defined($self->data->{type_id}) &&
$loaded->{LabelType}->{ $self->data->{type_id} },
label_code => $self->data->{label_code},
area => defined($self->data->{area_id}) &&
($loaded->{Area}->{ $self->data->{area_id} } // Area->new()),
comment => $self->data->{comment},
comment => $self->data->{comment} // '',
ipi_codes => $self->data->{ipi_codes},
isni_codes => $self->data->{isni_codes},
begin_date => MusicBrainz::Server::Entity::PartialDate->new_from_row($self->data->{begin_date}),
end_date => MusicBrainz::Server::Entity::PartialDate->new_from_row($self->data->{end_date}),
ended => $self->data->{ended}
ended => boolean_to_json($self->data->{ended})
};
}

Expand Down
3 changes: 2 additions & 1 deletion lib/MusicBrainz/Server/Edit/Medium/Edit.pm
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ sub build_display_data
join('', $_->name, $_->join_phrase // '')
} $track->artist_credit->all_names
),
$track->is_data_track ? 1 : 0
$track->is_data_track ? 1 : 0,
$track->position ? 1 : 0,
);
}
) }
Expand Down
7 changes: 5 additions & 2 deletions lib/MusicBrainz/Server/Edit/Recording/AddISRCs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use aliased 'MusicBrainz::Server::Entity::ISRC';
sub edit_type { $EDIT_RECORDING_ADD_ISRCS }
sub edit_name { N_l('Add ISRCs') }
sub edit_kind { 'add' }
sub edit_template_react { 'AddIsrcs' }

sub recording_ids { map { $_->{recording}{id} } @{ shift->data->{isrcs} } }

Expand Down Expand Up @@ -82,11 +83,13 @@ sub build_display_data
additions => [
map { +{
recording => $loaded->{Recording}{ $_->{recording}{id} }
|| Recording->new( name => $_->{recording}{name} ),
|| Recording->new( id => $_->{recording}{id}, name => $_->{recording}{name} ),
isrc => ISRC->new( isrc => $_->{isrc} ),
source => $_->{source}
} } @{ $self->data->{isrcs} }
]
],
client_version => $self->data->{client_version},

}
}

Expand Down
7 changes: 6 additions & 1 deletion lib/MusicBrainz/Server/Edit/Recording/RemoveISRC.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ with 'MusicBrainz::Server::Edit::Role::AllowAmending' => {
sub edit_name { N_l('Remove ISRC') }
sub edit_kind { 'remove' }
sub edit_type { $EDIT_RECORDING_REMOVE_ISRC }
sub edit_template_react { 'RemoveIsrc' }

sub recording_id { shift->data->{recording}{id} }

Expand Down Expand Up @@ -58,7 +59,11 @@ method build_display_data ($loaded)
ISRC->new(
isrc => $self->data->{isrc}{isrc},
recording => $loaded->{Recording}{ $self->data->{recording}{id} } //
Recording->new( name => $self->data->{recording}{name} ),
Recording->new(
id => $self->data->{recording}{id},
name => $self->data->{recording}{name}
),
recording_id => $self->data->{recording}{id},
);

return { isrc => $isrc };
Expand Down
8 changes: 7 additions & 1 deletion lib/MusicBrainz/Server/Edit/Relationship/AddLinkAttribute.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ with 'MusicBrainz::Server::Edit::Role::AlwaysAutoEdit';
sub edit_name { N_l('Add relationship attribute') }
sub edit_kind { 'add' }
sub edit_type { $EDIT_RELATIONSHIP_ADD_ATTRIBUTE }
sub edit_template_react { 'AddRelationshipAttribute' }

has '+data' => (
isa => Dict[
Expand All @@ -35,8 +36,13 @@ sub foreign_keys
sub build_display_data
{
my ($self, $loaded) = @_;
my $parent_id = $self->data->{parent_id};

return {
parent => $loaded->{LinkAttributeType}->{ $self->data->{parent_id} }
child_order => $self->data->{child_order},
description => $self->data->{description},
name => $self->data->{name},
parent => defined $parent_id ? $loaded->{LinkAttributeType}->{ $parent_id } : undef
}
}

Expand Down
2 changes: 2 additions & 0 deletions lib/MusicBrainz/Server/Edit/Relationship/Create.pm
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ sub build_display_data
grep { !exists $loaded->{LinkAttributeType}{$_->{type}{id}} }
@{ $self->data->{attributes} // [] }
)),
source_type => $type0,
target_type => $type1,
entity0 => defined $entity0->id ? undef : $entity0,
entity1 => defined $entity1->id ? undef : $entity1,
}
Expand Down
3 changes: 2 additions & 1 deletion lib/MusicBrainz/Server/Edit/Relationship/Delete.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ sub foreign_keys
$ids{$self->model1}->{gid_or_id($entity1)} = [ 'ArtistCredit' ];

$ids{LinkType} = [$self->data->{link}{type}{id}];
$ids{LinkAttributeType} = { map { $_->{type}{id} => ['LinkAttributeType'] } @{ $self->data->{relationship}{link}{attributes} // [] } };

return \%ids;
}
Expand All @@ -111,7 +112,7 @@ sub build_display_data
my $type = $_->{type};
MusicBrainz::Server::Entity::LinkAttribute->new(
type_id => $type->{id},
type => MusicBrainz::Server::Entity::LinkAttributeType->new(
type => $loaded->{LinkAttributeType}{$type->{id}} // MusicBrainz::Server::Entity::LinkAttributeType->new(
id => $type->{id},
name => $type->{name},
root_id => $type->{root}{id},
Expand Down
1 change: 1 addition & 0 deletions lib/MusicBrainz/Server/Edit/Release/AddReleaseLabel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ sub edit_name { N_l('Add release label') }
sub edit_kind { 'add' }
sub edit_type { $EDIT_RELEASE_ADDRELEASELABEL }
sub alter_edit_pending { { Release => [ shift->release_id ] } }
sub edit_template_react { 'AddReleaseLabel' }

use aliased 'MusicBrainz::Server::Entity::Label';
use aliased 'MusicBrainz::Server::Entity::Release';
Expand Down

0 comments on commit daeabfd

Please sign in to comment.