New: Include with files in album group info

This commit is contained in:
Bogdan 2024-07-14 13:25:24 +03:00
parent 30e681e843
commit eb04673040
5 changed files with 37 additions and 17 deletions

View file

@ -12,16 +12,13 @@ import TrackRowConnector from './TrackRowConnector';
import styles from './AlbumDetailsMedium.css'; import styles from './AlbumDetailsMedium.css';
function getMediumStatistics(tracks) { function getMediumStatistics(tracks) {
let trackCount = 0; const trackCount = tracks.length;
let trackFileCount = 0; let trackFileCount = 0;
let totalTrackCount = 0; let totalTrackCount = 0;
tracks.forEach((track) => { tracks.forEach((track) => {
if (track.trackFileId) { if (track.trackFileId) {
trackCount++;
trackFileCount++; trackFileCount++;
} else {
trackCount++;
} }
totalTrackCount++; totalTrackCount++;

View file

@ -10,6 +10,7 @@ function AlbumGroupInfo(props) {
const { const {
totalAlbumCount, totalAlbumCount,
monitoredAlbumCount, monitoredAlbumCount,
albumFileCount,
trackFileCount, trackFileCount,
sizeOnDisk sizeOnDisk
} = props; } = props;
@ -30,6 +31,13 @@ function AlbumGroupInfo(props) {
data={monitoredAlbumCount} data={monitoredAlbumCount}
/> />
<DescriptionListItem
titleClassName={styles.title}
descriptionClassName={styles.description}
title={translate('WithFiles')}
data={albumFileCount}
/>
<DescriptionListItem <DescriptionListItem
titleClassName={styles.title} titleClassName={styles.title}
descriptionClassName={styles.description} descriptionClassName={styles.description}
@ -50,6 +58,7 @@ function AlbumGroupInfo(props) {
AlbumGroupInfo.propTypes = { AlbumGroupInfo.propTypes = {
totalAlbumCount: PropTypes.number.isRequired, totalAlbumCount: PropTypes.number.isRequired,
monitoredAlbumCount: PropTypes.number.isRequired, monitoredAlbumCount: PropTypes.number.isRequired,
albumFileCount: PropTypes.number.isRequired,
trackFileCount: PropTypes.number.isRequired, trackFileCount: PropTypes.number.isRequired,
sizeOnDisk: PropTypes.number.isRequired sizeOnDisk: PropTypes.number.isRequired
}; };

View file

@ -160,7 +160,7 @@ class AlbumRow extends Component {
return ( return (
<TableRowCell key={name}> <TableRowCell key={name}>
{ {
statistics.totalTrackCount totalTrackCount
} }
</TableRowCell> </TableRowCell>
); );

View file

@ -22,32 +22,43 @@ import styles from './ArtistDetailsSeason.css';
function getAlbumStatistics(albums) { function getAlbumStatistics(albums) {
let albumCount = 0; let albumCount = 0;
let albumFileCount = 0;
let trackFileCount = 0; let trackFileCount = 0;
let totalAlbumCount = 0; let totalAlbumCount = 0;
let monitoredAlbumCount = 0; let monitoredAlbumCount = 0;
let hasMonitoredAlbums = false; let hasMonitoredAlbums = false;
let sizeOnDisk = 0; let sizeOnDisk = 0;
albums.forEach((album) => { albums.forEach(({ monitored, releaseDate, statistics = {} }) => {
if (album.statistics) { const {
sizeOnDisk = sizeOnDisk + album.statistics.sizeOnDisk; trackFileCount: albumTrackFileCount = 0,
trackFileCount = trackFileCount + album.statistics.trackFileCount; totalTrackCount: albumTotalTrackCount = 0,
sizeOnDisk: albumSizeOnDisk = 0
} = statistics;
if (album.statistics.trackFileCount === album.statistics.totalTrackCount || (album.monitored && isBefore(album.airDateUtc))) { const hasFiles = albumTrackFileCount > 0 && albumTrackFileCount === albumTotalTrackCount;
if (hasFiles || (monitored && isBefore(releaseDate))) {
albumCount++; albumCount++;
} }
if (hasFiles) {
albumFileCount++;
} }
if (album.monitored) { if (monitored) {
monitoredAlbumCount++; monitoredAlbumCount++;
hasMonitoredAlbums = true; hasMonitoredAlbums = true;
} }
totalAlbumCount++; totalAlbumCount++;
trackFileCount = trackFileCount + albumTrackFileCount;
sizeOnDisk = sizeOnDisk + albumSizeOnDisk;
}); });
return { return {
albumCount, albumCount,
albumFileCount,
totalAlbumCount, totalAlbumCount,
trackFileCount, trackFileCount,
monitoredAlbumCount, monitoredAlbumCount,
@ -56,8 +67,8 @@ function getAlbumStatistics(albums) {
}; };
} }
function getAlbumCountKind(monitored, albumCount, monitoredAlbumCount) { function getAlbumCountKind(monitored, albumCount, albumFileCount) {
if (albumCount === monitoredAlbumCount && monitoredAlbumCount > 0) { if (albumCount === albumFileCount && albumFileCount > 0) {
return kinds.SUCCESS; return kinds.SUCCESS;
} }
@ -192,6 +203,7 @@ class ArtistDetailsSeason extends Component {
const { const {
albumCount, albumCount,
albumFileCount,
totalAlbumCount, totalAlbumCount,
trackFileCount, trackFileCount,
monitoredAlbumCount, monitoredAlbumCount,
@ -226,9 +238,9 @@ class ArtistDetailsSeason extends Component {
anchor={ anchor={
<Label <Label
size={sizes.LARGE} size={sizes.LARGE}
kind={getAlbumCountKind(hasMonitoredAlbums, albumCount, monitoredAlbumCount)} kind={getAlbumCountKind(hasMonitoredAlbums, albumCount, albumFileCount)}
> >
<span>{albumCount} / {monitoredAlbumCount}</span> <span>{albumFileCount} / {albumCount}</span>
</Label> </Label>
} }
title={translate('GroupInformation')} title={translate('GroupInformation')}
@ -237,6 +249,7 @@ class ArtistDetailsSeason extends Component {
<AlbumGroupInfo <AlbumGroupInfo
totalAlbumCount={totalAlbumCount} totalAlbumCount={totalAlbumCount}
monitoredAlbumCount={monitoredAlbumCount} monitoredAlbumCount={monitoredAlbumCount}
albumFileCount={albumFileCount}
trackFileCount={trackFileCount} trackFileCount={trackFileCount}
sizeOnDisk={sizeOnDisk} sizeOnDisk={sizeOnDisk}
/> />

View file

@ -1294,6 +1294,7 @@
"WatchRootFoldersForFileChanges": "Watch Root Folders for file changes", "WatchRootFoldersForFileChanges": "Watch Root Folders for file changes",
"WeekColumnHeader": "Week Column Header", "WeekColumnHeader": "Week Column Header",
"WhatsNew": "What's New?", "WhatsNew": "What's New?",
"WithFiles": "With Files",
"WouldYouLikeToRestoreBackup": "Would you like to restore the backup '{name}'?", "WouldYouLikeToRestoreBackup": "Would you like to restore the backup '{name}'?",
"WriteAudioTagsHelpTextWarning": "Selecting 'All files' will alter existing files when they are imported.", "WriteAudioTagsHelpTextWarning": "Selecting 'All files' will alter existing files when they are imported.",
"WriteMetadataTags": "Write Metadata Tags", "WriteMetadataTags": "Write Metadata Tags",