Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
MBS-11117: Create report for too long discIDs
- Loading branch information
Showing
9 changed files
with
221 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package MusicBrainz::Server::Report::CDTOCDubiousLength; | ||
use Moose; | ||
|
||
with 'MusicBrainz::Server::Report::CDTOCReport'; | ||
|
||
sub table { 'cd_toc_dubious_length' } | ||
sub component_name { 'CDTocDubiousLength' } | ||
|
||
sub query { | ||
q{ | ||
SELECT | ||
cdtoc.id AS cdtoc_id, | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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(@_); | ||
|
||
my $cdtocs = $self->c->model('CDTOC')->get_by_ids( | ||
map { $_->{cdtoc_id} } @$items | ||
); | ||
|
||
return [ | ||
map +{ | ||
%$_, | ||
cdtoc => $cdtocs->{ $_->{cdtoc_id} }, | ||
}, @$items | ||
]; | ||
}; | ||
|
||
1; | ||
|
||
=head1 COPYRIGHT | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* @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 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* @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 CDTocLink | ||
from '../../static/scripts/common/components/CDTocLink'; | ||
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.cdtoc ? ( | ||
<> | ||
<td> | ||
<CDTocLink | ||
cdToc={item.cdtoc} | ||
content={item.cdtoc.discid} | ||
/> | ||
</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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters