Skip to content

Commit

Permalink
Merge branch 'master' into beta
Browse files Browse the repository at this point in the history
* master:
  Update POT files using the production database
  Update translations from Transifex
  MBS-11650: Add tag and rating statistics to profile page
  Remove unneeded exp.
  MBS-11622: Clean up Apple Music label URLs (#2086)
  MBS-11875: Don't consider Braille an unlikely script (#2224)
  MBS-11846: Display release artist on release group view (#2201)
  Removing useless empty {}
  MBS-11839: Convert Remove Relationship Attribute edit to React
  MBS-11823: Don't break tags and genres mid-word (#2214)
  MBS-11837: Convert Edit Release Label edit to React (#2212)
  MBS-11836: Convert Edit Barcodes edit to React (#2209)
  Make guess case files flow strict
  Add flow types to GuessCase/Main
  Convert GuessCase/Main to a class
  Add flow types to guess case handlers
  Clarify variable names in guess case handlers
  Fix eslint issues in guess case handlers
  Fix typo: asterix -> asterisk
  Convert guess case handlers to classes
  Replace file-loader with asset modules
  Change artist id in t/sql/coverart.sql
  Remove @babel/register from node-runner
  Remove the TemplateMacros tests
  Migrate to Webpack v5
  Remove .js from manifest.js paths
  Remove copy-webpack-plugin
  Remove EnvironmentPlugin
  Remove 'url' imports
  Bump copy-webpack-plugin to 6.4.0
  Bump webpack-node-externals to 3.0.0
  Bump webpack-manifest-plugin to 2.2.0
  Bump terser-webpack-plugin to 4.2.3
  Bump less-loader to 7.3.0
  Migrate less from v2 to v4
  Bump imports-loader to 1.2.0
  Bump file-loader to 6.2.0
  Bump webpack-cli to 3.3.12
  Bump Webpack to 4.46.0
  • Loading branch information
mwiencek committed Aug 19, 2021
2 parents 510d7b0 + a41236e commit aceb193
Show file tree
Hide file tree
Showing 173 changed files with 6,222 additions and 6,769 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Expand Up @@ -45,7 +45,8 @@ jobs:
rm /etc/service/{postgresql,redis}/down && sv start postgresql redis
sudo -E -H -u musicbrainz carton exec -- ./script/create_test_db.sh
sudo -E -H -u musicbrainz make -C po all_quiet deploy
NODE_ENV=test WEBPACK_MODE=development sudo -E -H -u musicbrainz carton exec -- ./script/compile_resources.sh server web-tests
NODE_ENV=test WEBPACK_MODE=development NO_PROGRESS=1 sudo -E -H -u musicbrainz carton exec -- \
./script/compile_resources.sh client server web-tests
sudo -E -H -u musicbrainz ./node_modules/.bin/flow --quiet
sudo -E -H -u musicbrainz ./node_modules/.bin/eslint --max-warnings 0 .
rm /etc/service/chrome/down && sv start chrome
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.yaml
Expand Up @@ -24,6 +24,7 @@ globals:
__webpack_public_path__: writable
__DEV__: readonly
GLOBAL_JS_NAMESPACE: readonly
MUSICBRAINZ_RUNNING_TESTS: readonly
addColon: readonly
addColonText: readonly
hasOwnProp: readonly
Expand Down
2 changes: 1 addition & 1 deletion docker/musicbrainz-tests/run_selenium_tests.sh
Expand Up @@ -52,7 +52,7 @@ sv start artwork-indexer artwork-redirect ssssss
# Compile static resources.
sudo -E -H -u musicbrainz yarn
sudo -E -H -u musicbrainz make -C po all_quiet deploy
NODE_ENV=test WEBPACK_MODE=development \
NODE_ENV=test WEBPACK_MODE=development NO_PROGRESS=1 \
sudo -E -H -u musicbrainz carton exec -- ./script/compile_resources.sh

# Add mbtest host alias to work around NO_PROXY restriction.
Expand Down
1 change: 0 additions & 1 deletion docker/templates/macros.m4
Expand Up @@ -38,7 +38,6 @@ install_javascript(`$1')

copy_mb(``root/ root/'')
copy_mb(``script/compile_resources.sh script/dbdefs_to_js.pl script/start_renderer.pl script/xgettext.js script/'')
copy_mb(``webpack.client.config.js webpack.server.config.js webpack.tests.config.js ./'')
copy_mb(``webpack/ webpack/'')

ENV NODE_ENV production
Expand Down
5 changes: 5 additions & 0 deletions flow-typed/npm/detect-node_v2.x.x.js
@@ -0,0 +1,5 @@
// @flow strict

declare module 'detect-node' {
declare module.exports: boolean;
}
1 change: 1 addition & 0 deletions lib/MusicBrainz/Server/Controller/ReleaseGroup.pm
Expand Up @@ -78,6 +78,7 @@ sub show : Chained('load') PathPart('') {

$c->model('Release')->load_related_info(@$releases);
$c->model('Release')->load_meta(@$releases);
$c->model('ArtistCredit')->load(@$releases);
$c->model('ReleaseStatus')->load(@$releases);
$c->model('CritiqueBrainz')->load_display_reviews($rg)
unless $self->should_return_jsonld($c);
Expand Down
2 changes: 2 additions & 0 deletions lib/MusicBrainz/Server/Controller/User.pm
Expand Up @@ -447,6 +447,7 @@ sub profile : Chained('load') PathPart('') HiddenOnSlaves
my $edit_stats = $c->model('Editor')->various_edit_counts($user->id);
$edit_stats->{last_day_count} = $c->model('Editor')->last_24h_edit_count($user->id);
my $added_entities = $c->model('Editor')->added_entities_counts($user->id);
my $secondary_stats = $c->model('Editor')->secondary_counts($user->id, $c->stash->{viewing_own_profile});

my @ip_hashes;
if ($c->user_exists && $c->user->is_account_admin && !(
Expand All @@ -465,6 +466,7 @@ sub profile : Chained('load') PathPart('') HiddenOnSlaves
user => $c->unsanitized_editor_json($user),
votes => $c->stash->{votes},
addedEntities => $added_entities,
secondaryStats => $secondary_stats,
);

$c->stash(
Expand Down
63 changes: 63 additions & 0 deletions lib/MusicBrainz/Server/Data/Editor.pm
Expand Up @@ -714,6 +714,69 @@ sub added_entities_counts {
return \%result;
}

sub secondary_counts {
my ($self, $editor_id, $viewing_own_profile) = @_;

my $editor = $self->get_by_id($editor_id);
$self->load_preferences($editor);

my %result;

if ($viewing_own_profile || $editor->preferences->public_tags) {
$result{upvoted_tag_count} = 0;
$result{downvoted_tag_count} = 0;

my @tag_tables = entities_with(
'tags',
take => sub { shift . '_tag_raw' },
);
my $tag_inner_query = join(
' UNION ALL ',
map { "SELECT is_upvote FROM $_ WHERE editor = ?" } @tag_tables
);

my $query = <<~SQL;
SELECT x.is_upvote, count(*)
FROM ($tag_inner_query) x
GROUP BY x.is_upvote
SQL

my $rows = $self->sql->select_list_of_lists(
$query,
($editor_id) x scalar @tag_tables,
);

for my $row (@$rows) {
my ($is_upvote, $count) = @$row;
if ($is_upvote) {
$result{upvoted_tag_count} = $count + 0;
} else {
$result{downvoted_tag_count} = $count + 0;
}
}
}

if ($viewing_own_profile || $editor->preferences->public_ratings) {
my @rating_tables = entities_with(
'ratings',
take => sub { shift . '_rating_raw' },
);
my $rating_inner_query = join(
' UNION ALL ',
map { "SELECT 1 FROM $_ WHERE editor = ?" } @rating_tables
);

my $query = "SELECT count(*) FROM ($rating_inner_query) x";

$result{rating_count} = $self->sql->select_single_value(
$query,
($editor_id) x scalar @rating_tables,
);
}

return \%result;
}

sub last_24h_edit_count
{
my ($self, $editor_id) = @_;
Expand Down
1 change: 1 addition & 0 deletions lib/MusicBrainz/Server/Data/FileCache.pm
Expand Up @@ -79,6 +79,7 @@ sub path_to {
my ($self, $manifest) = @_;

$manifest =~ s/^\///;
$manifest =~ s/\.js(on)?$//;
return DBDefs->STATIC_RESOURCES_LOCATION . '/' .
($self->manifest_signature($manifest) // $manifest);
}
Expand Down
10 changes: 10 additions & 0 deletions lib/MusicBrainz/Server/Edit/Relationship/RemoveLinkAttribute.pm
Expand Up @@ -13,6 +13,7 @@ with 'MusicBrainz::Server::Edit::Role::AlwaysAutoEdit';
sub edit_name { N_l('Remove relationship attribute') }
sub edit_kind { 'remove' }
sub edit_type { $EDIT_RELATIONSHIP_REMOVE_LINK_ATTRIBUTE }
sub edit_template_react { 'RemoveRelationshipAttribute' }

has '+data' => (
isa => Dict[
Expand All @@ -24,6 +25,15 @@ has '+data' => (
]
);

sub build_display_data {
my ($self, $loaded) = @_;

return {
description => $self->data->{description},
name => $self->data->{name},
};
}

sub accept {
my $self = shift;
$self->c->model('LinkAttributeType')->delete($self->data->{id})
Expand Down
10 changes: 6 additions & 4 deletions lib/MusicBrainz/Server/Edit/Release/EditBarcodes.pm
Expand Up @@ -4,6 +4,7 @@ use namespace::autoclean;

use MusicBrainz::Server::Constants qw( $EDIT_RELEASE_EDIT_BARCODES );
use MusicBrainz::Server::Edit::Types qw( Nullable );
use MusicBrainz::Server::Entity::Util::JSON qw( to_json_object );
use MusicBrainz::Server::Translation qw( N_l );
use MooseX::Types::Moose qw( ArrayRef Int Str );
use MooseX::Types::Structured qw( Dict );
Expand All @@ -19,6 +20,7 @@ use aliased 'MusicBrainz::Server::Entity::Release';
sub edit_name { N_l('Edit barcodes') }
sub edit_kind { 'edit' }
sub edit_type { $EDIT_RELEASE_EDIT_BARCODES }
sub edit_template_react { 'EditBarcodes' }

has '+data' => (
isa => Dict[
Expand Down Expand Up @@ -56,13 +58,13 @@ sub build_display_data
{
my ($self, $loaded) = @_;
return {
client_version => $self->data->{client_version},
submissions => [
map +{
release => ($loaded->{Release}{ $_->{release}{id} } ||
release => to_json_object($loaded->{Release}{ $_->{release}{id} } ||
Release->new( name => $_->{release}{name} )),
new_barcode => Barcode->new($_->{barcode}),
exists $_->{old_barcode} ?
(old_barcode => Barcode->new($_->{old_barcode})) : ()
new_barcode => $_->{barcode},
exists $_->{old_barcode} ? (old_barcode => $_->{old_barcode}) : ()
}, @{ $self->data->{submissions} }
]
}
Expand Down
32 changes: 19 additions & 13 deletions lib/MusicBrainz/Server/Edit/Release/EditReleaseLabel.pm
Expand Up @@ -28,6 +28,7 @@ with 'MusicBrainz::Server::Edit::Role::AlwaysAutoEdit';
sub edit_name { N_l('Edit release label') }
sub edit_kind { 'edit' }
sub edit_type { $EDIT_RELEASE_EDITRELEASELABEL }
sub edit_template_react { 'EditReleaseLabel' }

sub alter_edit_pending { { Release => [ shift->release_id ] } }

Expand Down Expand Up @@ -109,9 +110,12 @@ sub build_display_data {
my $data = $self->data;

my $display_data = {
release => $loaded->{Release}{ gid_or_id($data->{release}) } // Release->new(name => $data->{release}{name}),
release => to_json_object(
$loaded->{Release}{ gid_or_id($data->{release}) } //
Release->new(name => $data->{release}{name})
),
catalog_number => {
new => $data->{new}{catalog_number},
exists $data->{new}{catalog_number} ? (new => $data->{new}{catalog_number}) : (),
old => $data->{old}{catalog_number},
},
barcode => $data->{release}{barcode}
Expand All @@ -129,26 +133,28 @@ sub build_display_data {
my $country = $_->{country};
my $country_gid_or_id = gid_or_id($country);

$event_display->{country} = defined $country_gid_or_id && $loaded->{Area}{$country_gid_or_id};
$event_display->{country} //= defined $country->{name} && MusicBrainz::Server::Entity::Area->new($country);
$event_display->{country} = to_json_object(
defined $country_gid_or_id && $loaded->{Area}{$country_gid_or_id}
);
$event_display->{country} //= to_json_object(
defined $country->{name} && MusicBrainz::Server::Entity::Area->new($country)
);
}

$event_display->{date} = MusicBrainz::Server::Entity::PartialDate->new($_->{date});
$event_display->{date} = to_json_object(
MusicBrainz::Server::Entity::PartialDate->new($_->{date})
);
$event_display;
} @{ $data->{release}{events} // [] }
];

$display_data->{events_json} = [
map +{
country => to_json_object($_->{country}),
date => to_json_object($_->{date}),
}, @{ $display_data->{events} }
];

for (qw( new old )) {
if (my $label = $data->{$_}{label}) {
next unless %$label;
$display_data->{label}{$_} = $loaded->{Label}{gid_or_id($label)} // Label->new(name => $label->{name});
$display_data->{label}{$_} = to_json_object(
$loaded->{Label}{gid_or_id($label)} //
Label->new(name => $label->{name})
);
}
}

Expand Down
Expand Up @@ -22,15 +22,15 @@ sub query {
JOIN script ON r.script = script.id
JOIN language ON r.language = language.id
WHERE (
script.iso_code NOT IN ('Kana', 'Latn', 'Qaaa') AND
script.iso_code NOT IN ('Brai', 'Kana', 'Latn', 'Qaaa') AND
language.iso_code_3 IN (
'eng', 'spa', 'deu', 'fra', 'por', 'ita', 'swe', 'nor', 'fin',
'est', 'lav', 'lit', 'pol', 'nld', 'cat', 'hun', 'ces', 'slk',
'dan', 'ron', 'slv', 'hrv'
)
) OR (
language.iso_code_3 = 'jpn' AND
script.iso_code NOT IN ('Hira', 'Hrkt', 'Kana', 'Jpan', 'Latn', 'Qaaa')
script.iso_code NOT IN ('Brai', 'Hira', 'Hrkt', 'Kana', 'Jpan', 'Latn', 'Qaaa')
)
";
}
Expand Down
23 changes: 11 additions & 12 deletions package.json
Expand Up @@ -25,26 +25,24 @@
"@popperjs/core": "2.5.3",
"@sentry/browser": "5.10.2",
"@sentry/node": "5.10.2",
"babel-loader": "8.1.0",
"babel-loader": "8.2.2",
"balanced-match": "0.2.0",
"canonical-json": "0.0.4",
"cookie": "0.4.0",
"copy-webpack-plugin": "4.6.0",
"core-js": "3.6.5",
"detect-node": "2.0.3",
"file-loader": "3.0.1",
"filesize": "2.0.4",
"generic-diff": "1.0.1",
"he": "1.1.1",
"imports-loader": "0.8.0",
"imports-loader": "3.0.0",
"jed": "git://github.com/mwiencek/Jed.git#cd3f71b",
"jquery": "1.11.2",
"knockout": "git://github.com/mwiencek/knockout.git#a09f077",
"knockout-arraytransforms": "git://github.com/mwiencek/knockout-arraytransforms.git#9673e91",
"leaflet": "1.6.0",
"leaflet.markercluster": "1.4.1",
"less": "2.7.3",
"less-loader": "4.1.0",
"less": "4.1.1",
"less-loader": "10.0.1",
"less-plugin-clean-css": "1.5.1",
"leven": "2.0.0",
"mutate-cow": "4.0.3",
Expand All @@ -61,18 +59,17 @@
"shelljs": "0.8.4",
"sliced": "1.0.1",
"tablesorter": "2.31.3",
"terser-webpack-plugin": "1.3.0",
"webpack": "4.29.3",
"webpack-cli": "3.2.3",
"webpack-manifest-plugin": "2.0.4",
"webpack-node-externals": "1.7.2",
"terser-webpack-plugin": "5.1.4",
"webpack": "5.50.0",
"webpack-node-externals": "3.0.0",
"whatwg-fetch": "3.4.0",
"yargs": "3.10.0"
},
"devDependencies": {
"@babel/cli": "7.14.8",
"@babel/eslint-parser": "7.15.0",
"babel-plugin-istanbul": "5.2.0",
"buffer": "6.0.3",
"chrome-remote-interface": "0.27.0",
"eslint": "7.9.0",
"eslint-plugin-fb-flow": "0.0.2",
Expand All @@ -84,10 +81,12 @@
"flow-bin": "0.157.0",
"gettext-parser": "3.1.0",
"http-proxy": "1.18.1",
"jsdom": "13.2.0",
"json5": "2.1.3",
"nyc": "14.1.1",
"path-browserify": "1.0.1",
"process": "0.11.10",
"selenium-webdriver": "4.0.0-alpha.5",
"stream-browserify": "3.0.0",
"tap-difflet": "0.7.2",
"tap-junit": "3.1.0",
"tape": "4.7.0",
Expand Down

0 comments on commit aceb193

Please sign in to comment.