Skip to content

Commit

Permalink
MBS-11117: Create report for too long discIDs
Browse files Browse the repository at this point in the history
DiscIDs should be assigned to only CD format mediums and should not be
above 80-something minutes. CDTOC above the cutoff (set to 100 minutes
here) were probably created with a buggy version of foo_musicbrainz and
can be removed.
  • Loading branch information
loujine committed Sep 19, 2020
1 parent f34f625 commit eab9a16
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 0 deletions.
41 changes: 41 additions & 0 deletions lib/MusicBrainz/Server/Report/CdTocDubiousLength.pm
@@ -0,0 +1,41 @@
package MusicBrainz::Server::Report::CdTocDubiousLength;
use Moose;

with 'MusicBrainz::Server::Report::CdTocReport';

sub component_name { 'CdTocDubiousLength' }

sub query {
q{
SELECT
cdtoc.discid,
medium_format.name AS format,
cdtoc.leadout_offset / 75 AS length, -- seconds
row_number() OVER (
ORDER BY medium_format.name, cdtoc.leadout_offset DESC)
FROM
cdtoc
JOIN medium_cdtoc ON medium_cdtoc.cdtoc = cdtoc.id
JOIN medium ON medium_cdtoc.medium = medium.id
JOIN medium_format ON medium.format = medium_format.id
WHERE
leadout_offset > 75 * 60 * 100 -- cutoff 100 minutes
ORDER BY
medium_format.name,
cdtoc.leadout_offset DESC
}
}

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

=head1 COPYRIGHT AND LICENSE
Copyright (C) 2020 Jerome Roy
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
37 changes: 37 additions & 0 deletions lib/MusicBrainz/Server/Report/CdTocReport.pm
@@ -0,0 +1,37 @@
package MusicBrainz::Server::Report::CdTocReport;
use Moose::Role;

with 'MusicBrainz::Server::Report::QueryReport';

around inflate_rows => sub {
my $orig = shift;
my $self = shift;

my $items = $self->$orig(@_);

return [
@$items
];
};

1;

=head1 COPYRIGHT
Copyright (C) 2020 Jerome Roy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
=cut
2 changes: 2 additions & 0 deletions lib/MusicBrainz/Server/ReportFactory.pm
Expand Up @@ -22,6 +22,7 @@ use MusicBrainz::Server::PagedReport;
BadAmazonURLs
CatNoLooksLikeASIN
CatNoLooksLikeLabelCode
CdTocDubiousLength
CollaborationRelationships
CoverArtRelationships
DeprecatedRelationshipArtists
Expand Down Expand Up @@ -105,6 +106,7 @@ use MusicBrainz::Server::Report::ArtistsWithNoSubscribers;
use MusicBrainz::Server::Report::BadAmazonURLs;
use MusicBrainz::Server::Report::CatNoLooksLikeASIN;
use MusicBrainz::Server::Report::CatNoLooksLikeLabelCode;
use MusicBrainz::Server::Report::CdTocDubiousLength;
use MusicBrainz::Server::Report::CollaborationRelationships;
use MusicBrainz::Server::Report::CoverArtRelationships;
use MusicBrainz::Server::Report::DeprecatedRelationshipArtists;
Expand Down
50 changes: 50 additions & 0 deletions root/report/CdTocDubiousLength.js
@@ -0,0 +1,50 @@
/*
* @flow strict-local
* Copyright (C) 2020 Jerome Roy
*
* 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
*/

import * as React from 'react';

import Layout from '../layout';
import formatUserDate from '../utility/formatUserDate';

import CdTocList from './components/CdTocList';
import FilterLink from './FilterLink';
import type {ReportDataT, ReportCdTocT} from './types';

const CdTocDubiousLength = ({
$c,
generated,
items,
pager,
}: ReportDataT<ReportCdTocT>): React.Element<typeof Layout> => (
<Layout $c={$c} fullWidth title={l('Disc IDs with dubious duration')}>
<h1>{l('Disc IDs with dubious duration')}</h1>

<ul>
<li>
{l(`This report shows disc IDs indicating a total duration much longer
than what a standard CD allows (at least 100 minutes). This usually
means a disc ID was created for the wrong format (SACD) or with a buggy
tool. These disc IDs can safely be removed.`)}
</li>
<li>
{texp.l('Total releases found: {count}',
{count: pager.total_entries})}
</li>
<li>
{texp.l('Generated on {date}',
{date: formatUserDate($c, generated)})}
</li>
</ul>

<CdTocList items={items} pager={pager} />

</Layout>
);

export default CdTocDubiousLength;
10 changes: 10 additions & 0 deletions root/report/ReportsIndex.js
Expand Up @@ -565,6 +565,16 @@ const ReportsIndex = ({$c}: Props): React.Element<typeof Layout> => (
</a>
</li>
</ul>

<h2>{l('Disc IDs')}</h2>

<ul>
<li>
<a href="/report/CdTocDubiousLength">
{l('Disc IDs with dubious duration')}
</a>
</li>
</ul>
</div>
</Layout>
);
Expand Down
71 changes: 71 additions & 0 deletions root/report/components/CdTocList.js
@@ -0,0 +1,71 @@
/*
* @flow strict-local
* Copyright (C) 2020 Jerome Roy
*
* 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
*/

import * as React from 'react';

import PaginatedResults from '../../components/PaginatedResults';
import loopParity from '../../utility/loopParity';
import type {ReportCdTocT} from '../types';
import formatTrackLength
from '../../static/scripts/common/utility/formatTrackLength';

type Props = {
+items: $ReadOnlyArray<ReportCdTocT>,
+pager: PagerT,
};

const CdTocList = ({
items,
pager,
}: Props): React.Element<typeof PaginatedResults> => {
const colSpan = 3;

return (
<PaginatedResults pager={pager}>
<table className="tbl">
<thead>
<tr>
<th>{l('Disc ID')}</th>
<th>{l('Format')}</th>
<th>{l('Length')}</th>
</tr>
</thead>
<tbody>
{items.map((item, index) => {
return (
<tr className={loopParity(index)} key={item.cdtoc_id}>
{item.discid ? (
<>
<td>
<a href={'/cdtoc/' + item.discid}>
{item.discid}
</a>
</td>
<td>
{item.format}
</td>
<td>
{formatTrackLength(1000 * item.length)}
</td>
</>
) : (
<td colSpan={colSpan}>
{l('This Disc ID no longer exists.')}
</td>
)}
</tr>
);
})}
</tbody>
</table>
</PaginatedResults>
);
};

export default CdTocList;
7 changes: 7 additions & 0 deletions root/report/types.js
Expand Up @@ -39,6 +39,13 @@ export type ReportArtistUrlT = {
+url: UrlT,
};

export type ReportCdTocT = {
+discid: string,
+format: string,
+length: number,
+row_number: number,
};

export type ReportCollaborationT = {
+artist0: ?ArtistT,
+artist1: ?ArtistT,
Expand Down
1 change: 1 addition & 0 deletions root/server/components.js
Expand Up @@ -139,6 +139,7 @@ module.exports = {
'report/BadAmazonUrls': require('../report/BadAmazonUrls'),
'report/CatNoLooksLikeAsin': require('../report/CatNoLooksLikeAsin'),
'report/CatNoLooksLikeLabelCode': require('../report/CatNoLooksLikeLabelCode'),
'report/CdTocDubiousLength': require('../report/CdTocDubiousLength'),
'report/CollaborationRelationships': require('../report/CollaborationRelationships'),
'report/CoverArtRelationships': require('../report/CoverArtRelationships'),
'report/DeprecatedRelationshipArtists': require('../report/DeprecatedRelationshipArtists'),
Expand Down

0 comments on commit eab9a16

Please sign in to comment.