Skip to content

Commit

Permalink
Merge branch 'beta' into production
Browse files Browse the repository at this point in the history
* beta:
  Add missing space
  Update POT files using the production database
  Update translations from Transifex
  MBS-11781: Add class to the "load all tracks" link on large mediums (#2172)
  Fix alignment of loading icon for media (#2171)
  Fix syntax error
  Update POT files using the production database
  Update translations from Transifex
  MBS-11679: Wish editors a happy MB anniversary (#2116)
  MBS-10367: Allow requesting copy of sent report when reporting (#1965)
  MBS-11747: Hide release details on edit preview (#2158)
  MBS-8371: Add searching in edit notes to the edit search (#1820)
  MBS-11443: Add option to sort edits by edit note date (#1980)
  MBS-11578: Link tracks in RecordingTrackDifferentName report (#2097)
  MBS-11711: Show informative error if no relationships in group (#2143)
  MBS-11782: Hide more irrelevant work rels from release's bottom credits (#2169)
  MBS-11335: Report for reused Wikidata items (#1871)
  MBS-11774: Add fullwidth feat / featuring to the featuring reports
  MBS-11772: Add Greek version to featured artist reports
  MBS-10844: Report for same URL linked to many entities
  MBS-11335: Report for reused Wikidata items
  MBS-11757: CD Japan -> CDJapan (#2157)
  MBS-11776: Readd "loading-message" class to the medium loading message (#2166)
  MBS-11767: Show track-level artists on loaded mediums (#2168)
  MBS-11778: Convert edit header to React (#2167)
  MBS-11773: Make "featuring in title" reports case insensitive (#2163)
  Bump Flow to 0.155.0
  Bump Flow to 0.154.0
  Replace last remaining `__proto__: empty` hack
  Return a Map from groupBy/keyBy
  Upgrade Flow to 0.153.0
  Rename toJS argument to entity
  MBS-11775: Do not break if relatedArtists is undefined
  MBS-11765: Add standalone recording statistics
  Corrected plural
  MBS-11769: Display # of recordings w ISRCs / works w ISWCs
  Fix sort
  MBS-11761: Properly display ratings on release lists
  MBS-11753: Fix selectors for RangeSelect in ArtistEdit (#2155)
  MBS-11744: Make it easier to mouse-select release dates in tables (#2154)
  MBS-11726: Add missing space to Set Cover Art display (#2153)
  Fix warning about \1 being better written as $1
  MBS-11381: Add forms for admins to add and update timeline events
  Deflate field values in Form::Role::ToJSON
  Correct track_count for INSERT INTO medium
  MBS-11614: Allow merging releases when a medium is empty
  MBS-11666: Report for releases that have disc IDs but shouldn't
  MBS-11664: Enable discID tabs when release (wrongly) has discIDs
  • Loading branch information
reosarevok committed Jul 19, 2021
2 parents a2e7e53 + 5b11406 commit 65858ef
Show file tree
Hide file tree
Showing 158 changed files with 15,623 additions and 11,975 deletions.
98 changes: 98 additions & 0 deletions lib/MusicBrainz/Server/Controller/Admin/StatisticsEvent.pm
@@ -0,0 +1,98 @@
package MusicBrainz::Server::Controller::Admin::StatisticsEvent;
use Moose;
use MusicBrainz::Server::Entity::Util::JSON qw( to_json_array );

BEGIN { extends 'MusicBrainz::Server::Controller' };

sub _form_to_hash {
my ($self, $form) = @_;
return map { $form->field($_)->name => $form->field($_)->value } $form->edit_field_names;
}

sub index : Path('/admin/statistics-events') Args(0) RequireAuth(account_admin) {
my ($self, $c) = @_;

$c->stash(
current_view => 'Node',
component_path => 'admin/statistics-events/StatisticsEventIndex',
component_props => {
events => to_json_array($c->model('Statistics')->all_events),
},
);
}

sub create : Path('/admin/statistics-events/create') RequireAuth(account_admin) SecureForm {
my ($self, $c) = @_;

my $form = $c->form( form => 'Admin::StatisticsEvent' );

if ($c->form_posted_and_valid($form)) {
my %insert = $self->_form_to_hash($form);
$c->model('MB')->with_transaction(sub {
$c->model('StatisticsEvent')->insert(\%insert);
});

$c->response->redirect($c->uri_for('/admin/statistics-events'));
}

$c->stash(
component_path => 'admin/statistics-events/CreateStatisticsEvent',
component_props => {form => $form->TO_JSON},
current_view => 'Node',
);
}

sub edit : Path('/admin/statistics-events/edit') Args(1) RequireAuth(account_admin) SecureForm {
my ($self, $c, $date) = @_;

my $event = $c->model('StatisticsEvent')->get_by_date($date);

my $form = $c->form( form => 'Admin::StatisticsEvent', init_object => $event);

if ($c->form_posted_and_valid($form)) {
$c->model('MB')->with_transaction(sub {
$c->model('StatisticsEvent')->update($date, { map { $_->name => $_->value } $form->edit_fields });
});

$c->response->redirect($c->uri_for('/admin/statistics-events'));
$c->detach;
}

$c->stash(
component_path => 'admin/statistics-events/EditStatisticsEvent',
component_props => {form => $form->TO_JSON},
current_view => 'Node',
);
}

sub delete : Path('/admin/statistics-events/delete') Args(1) RequireAuth(account_admin) SecureForm {
my ($self, $c, $date) = @_;

my $event = $c->model('StatisticsEvent')->get_by_date($date);

if ($c->form_posted) {
$c->model('MB')->with_transaction(sub {
$c->model('StatisticsEvent')->delete($date);
});

$c->response->redirect($c->uri_for('/admin/statistics-events'));
}

$c->stash(
component_path => 'admin/statistics-events/DeleteStatisticsEvent',
component_props => {event => $event->TO_JSON},
current_view => 'Node',
);
}

1;

=head1 COPYRIGHT AND LICENSE
Copyright (C) 2021 MetaBrainz Foundation
This file is part of MusicBrainz, the open internet music database,
and is licensed under the GPL version 2, or (at your option) any
later version: http://www.gnu.org/licenses/gpl-2.0.txt
=cut
15 changes: 11 additions & 4 deletions lib/MusicBrainz/Server/Controller/Role/Load.pm
Expand Up @@ -6,6 +6,7 @@ use MusicBrainz::Server::Data::Utils 'model_to_type';
use MusicBrainz::Server::Validation qw( is_guid is_positive_integer );
use MusicBrainz::Server::Constants qw( :direction %ENTITIES );
use Readonly;
use aliased 'MusicBrainz::Server::Entity::RelationshipLinkTypeGroup';

no if $] >= 5.018, warnings => "experimental::smartmatch";

Expand Down Expand Up @@ -116,13 +117,19 @@ role
);

if (defined $pager) {
if (!scalar @$lt_groups) {
$c->detach('/error_400');
}
if (scalar @$lt_groups > 1) {
die 'Expected only one link type group';
}
my $lt_group = $lt_groups->[0];

my $lt_group;
if (!scalar @$lt_groups) {
$lt_group = RelationshipLinkTypeGroup->new(
link_type_id => $link_type_id,
);
} else {
$lt_group = $lt_groups->[0];
}

$pager->total_entries($lt_group->total_relationships);
$c->stash->{pager} = $pager;
$c->stash->{paged_link_type_group} = $lt_group;
Expand Down
1 change: 1 addition & 0 deletions lib/MusicBrainz/Server/Controller/User.pm
Expand Up @@ -732,6 +732,7 @@ sub report : Chained('load') RequireAuth HiddenOnSlaves SecureForm {
reason => $form->value->{reason},
message => $form->value->{message},
reveal_address => $form->value->{reveal_address},
send_to_self => $form->value->{send_to_self},
);
} catch {
log_debug { "Couldn't send email: $_" } $_;
Expand Down
25 changes: 20 additions & 5 deletions lib/MusicBrainz/Server/Data/Release.pm
Expand Up @@ -55,6 +55,7 @@ Readonly::Hash our %RELEASE_MERGE_ERRORS => (
medium_missing => N_l('Some mediums being merged don’t have an equivalent on the target release: either the target release has less mediums, or the positions don’t match.'),
medium_positions => N_l('The medium positions conflict.'),
medium_track_counts => N_l('The track counts on at least one set of corresponding mediums do not match.'),
merging_into_empty => N_l('Merging a medium with tracks into one without them is not currently supported. You can always merge in the other direction!'),
pregaps => N_l('Mediums with a pregap track can only be merged with other mediums with a pregap track.'),
recording_merge_cycle => N_l('A merge cycle exists whereby two recordings ({recording1} and {recording2}) each want to merge into the other. This is likely because the tracks or recordings are in an inconsistent order on the releases.'),
);
Expand Down Expand Up @@ -939,11 +940,25 @@ sub can_merge {
});
}

my $medium_track_counts_differ = $self->sql->select_single_value(
"$mediums_query
WHERE new_medium.track_count <> s.track_count
LIMIT 1",
\@old_ids, $new_id);
my $merging_into_empty_medium = $self->sql->select_single_value(<<~"EOSQL", \@old_ids, $new_id);
$mediums_query
WHERE s.track_count > 0
AND new_medium.track_count = 0
LIMIT 1
EOSQL

if ($merging_into_empty_medium) {
return (0, {
message => $RELEASE_MERGE_ERRORS{merging_into_empty},
});
}

my $medium_track_counts_differ = $self->sql->select_single_value(<<~"EOSQL", \@old_ids, $new_id);
$mediums_query
WHERE new_medium.track_count <> s.track_count
AND s.track_count > 0
LIMIT 1
EOSQL

if ($medium_track_counts_differ) {
return (0, {
Expand Down
8 changes: 7 additions & 1 deletion lib/MusicBrainz/Server/Data/Statistics.pm
Expand Up @@ -774,8 +774,14 @@ my %stats = (
DESC => "Count of all recordings",
SQL => "SELECT COUNT(*) FROM recording",
},
"count.recording.standalone" => {
DESC => "Count of all standalone recordings",
SQL => "SELECT COUNT(*) FROM recording WHERE NOT EXISTS (
SELECT 1 FROM track WHERE track.recording = recording.id
)",
},
"count.video" => {
DESC => "Count of all video recording",
DESC => "Count of all video recordings",
SQL => "SELECT COUNT(*) FROM recording WHERE video",
},
"count.work" => {
Expand Down
61 changes: 61 additions & 0 deletions lib/MusicBrainz/Server/Data/StatisticsEvent.pm
@@ -0,0 +1,61 @@
package MusicBrainz::Server::Data::StatisticsEvent;
use Moose;
use namespace::autoclean;

use MusicBrainz::Server::Entity::StatisticsEvent;

extends 'MusicBrainz::Server::Data::Entity';
with 'MusicBrainz::Server::Data::Role::EntityCache';
with 'MusicBrainz::Server::Data::Role::SelectAll';
with 'MusicBrainz::Server::Data::Role::InsertUpdateDelete';

sub _type { 'statistics_event' }

sub _table
{
return 'statistics.statistic_event';
}

sub _id_column
{
return 'statistic_event.date';
}

sub _columns {
return 'date, title, description, link';
}

sub _column_mapping {
return {
date => 'date',
title => 'title',
description => 'description',
link => 'link',
};
}

sub _entity_class
{
return 'MusicBrainz::Server::Entity::StatisticsEvent';
}

sub get_by_date {
my ($self, $date) = @_;

my @events = $self->_get_by_keys('date', $date);
return $events[0];
}

__PACKAGE__->meta->make_immutable;
no Moose;
1;

=head1 COPYRIGHT AND LICENSE
Copyright (C) 2021 MetaBrainz Foundation
This file is part of MusicBrainz, the open internet music database,
and is licensed under the GPL version 2, or (at your option) any
later version: http://www.gnu.org/licenses/gpl-2.0.txt
=cut
28 changes: 5 additions & 23 deletions lib/MusicBrainz/Server/Edit.pm
Expand Up @@ -7,7 +7,7 @@ use MusicBrainz::Server::Data::Utils qw( boolean_to_json datetime_to_iso8601 );
use MusicBrainz::Server::Edit::Exceptions;
use MusicBrainz::Server::Edit::Utils qw( edit_status_name );
use MusicBrainz::Server::Entity::Types;
use MusicBrainz::Server::Entity::Util::JSON qw( to_json_array );
use MusicBrainz::Server::Entity::Util::JSON qw( add_linked_entity to_json_array );
use MusicBrainz::Server::Constants qw(
:edit_status
:expire_action
Expand Down Expand Up @@ -139,19 +139,6 @@ sub no_votes {
scalar shift->_grep_votes(sub { $_->vote == $VOTE_NO && !$_->superseded });
}

sub votes_for_editor
{
my ($self, $editor_id) = @_;
$self->_grep_votes(sub { $_->editor_id == $editor_id });
}

sub latest_vote_for_editor
{
my ($self, $editor_id) = @_;
my @votes = $self->votes_for_editor($editor_id) or return;
return $votes[-1];
}

sub is_open
{
return shift->status == $STATUS_OPEN;
Expand Down Expand Up @@ -233,15 +220,6 @@ sub editor_may_cancel {
&& $self->editor_id == $editor->id;
}

sub was_approved
{
my $self = shift;

return 0 if $self->is_open;

return scalar $self->_grep_votes(sub { $_->vote == $VOTE_APPROVE })
}

sub approval_requires_comment {
my ($self, $editor) = @_;

Expand Down Expand Up @@ -319,9 +297,12 @@ sub initialize
sub TO_JSON {
my ($self) = @_;

add_linked_entity('editor', $self->editor_id, $self->editor);

my $can_preview = $self->does('MusicBrainz::Server::Edit::Role::Preview');
my $conditions = $self->edit_conditions;
return {
auto_edit => boolean_to_json($self->auto_edit),
close_time => datetime_to_iso8601($self->close_time),
conditions => {
duration => $conditions->{duration} + 0,
Expand All @@ -333,6 +314,7 @@ sub TO_JSON {
display_data => $self->display_data,
data => $self->data,
edit_kind => $self->edit_kind,
edit_name => $self->edit_name,
edit_notes => to_json_array($self->edit_notes),
edit_type => $self->edit_type + 0,
editor_id => $self->editor_id + 0,
Expand Down
42 changes: 42 additions & 0 deletions lib/MusicBrainz/Server/EditSearch/Predicate/EditNoteContent.pm
@@ -0,0 +1,42 @@
package MusicBrainz::Server::EditSearch::Predicate::EditNoteContent;
use Moose;

with 'MusicBrainz::Server::EditSearch::Predicate';

sub operator_cardinality_map {
return (
'includes' => undef,
)
}

sub combine_with_query {
my ($self, $query) = @_;

my @patterns = map {
$_ =~ s/\\/\\\\/g;
$_ =~ s/_/\\_/g;
$_ =~ s/%/\\%/g;
'%' . $_ . '%'
} @{ $self->sql_arguments };

$query->add_where([
'EXISTS (
SELECT TRUE FROM edit_note
WHERE edit_note.text ILIKE ?
AND edit_note.edit = edit.id
)',
\@patterns,
]);
};

1;

=head1 COPYRIGHT AND LICENSE
Copyright (C) 2015-2017 MetaBrainz Foundation
This file is part of MusicBrainz, the open internet music database,
and is licensed under the GPL version 2, or (at your option) any
later version: http://www.gnu.org/licenses/gpl-2.0.txt
=cut

0 comments on commit 65858ef

Please sign in to comment.