Skip to content

Commit

Permalink
Fix: rename UNMATCHED report status to UNUSED (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Sep 23, 2023
1 parent 8688d68 commit a9f7353
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/output/reporting.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ When using DATs (the `--dat <path>` option), the `igir report` [command](../comm
- `FOUND`: what ROMs were found, and where the files are on disk
- `IGNORED`: what ROMs were ignored (due to [`--single` 1G1R rules](../roms/filtering-preferences.md))
- `MISSING`: what ROMs were wanted, but are missing
- `UNMATCHED`: what input files didn't match to any ROM
- `UNUSED`: what input files didn't match to any ROM
- `DELETED`: what output files were [cleaned](cleaning.md) (`igir clean` command)

At least one DAT is required for the `igir report` command to work, otherwise `igir` has no way to understand what input files are known ROMs and which aren't. See the [DAT docs](../input/dats.md) for more information about DATs.
Expand Down Expand Up @@ -47,7 +47,7 @@ See the `igir --help` message for the report's default location.

The output report format is a standard CSV that can be opened in Microsoft Excel, Apple Numbers, Google Sheets, LibreOffice Calc, and other similar spreadsheet applications.

Unlike the report formats of [other ROM managers](../alternatives.md), CSVs allow you to filter rows by column values. For example, you can filter the "Status" column to only "MISSING" to understand what ROMs are missing from your collection, or to "UNMATCHED" to understand what input files aren't recognized as a known ROM. The ability to filter CSVs in spreadsheet applications means that `igir` should not need use-case-specific report options to achieve your goal.
Unlike the report formats of [other ROM managers](../alternatives.md), CSVs allow you to filter rows by column values. For example, you can filter the "Status" column to only "MISSING" to understand what ROMs are missing from your collection, or to "UNUSED" to understand what input files weren't used as the source of any output file. The ability to filter CSVs in spreadsheet applications means that `igir` should not need use-case-specific report options to achieve your goal.

To perform this filtering, most spreadsheet applications have a button or menu item to "create a filter" or "auto filter."

Expand Down
10 changes: 5 additions & 5 deletions src/modules/reportGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ export default class ReportGenerator extends Module {
const releaseCandidates = datStatuses
.flatMap((datStatus) => datStatus.getReleaseCandidates())
.filter(ArrayPoly.filterNotNullish);
const matchedFiles = new Set(releaseCandidates
const usedFiles = new Set(releaseCandidates
.flatMap((releaseCandidate) => releaseCandidate.getRomsWithFiles())
.map((romWithFiles) => romWithFiles.getInputFile().getFilePath()));
const unmatchedFiles = scannedRomFiles
const unusedFiles = scannedRomFiles
.reduce(ArrayPoly.reduceUnique(), [])
.filter((inputFile) => !matchedFiles.has(inputFile))
.filter((inputFile) => !usedFiles.has(inputFile))
.sort();
const unmatchedCsv = await DATStatus.filesToCsv(unmatchedFiles, Status.UNMATCHED);
const unusedCsv = await DATStatus.filesToCsv(unusedFiles, Status.UNUSED);

const cleanedCsv = await DATStatus.filesToCsv(cleanedOutputFiles, Status.DELETED);

const rows = [...matchedFileCsvs, unmatchedCsv, cleanedCsv].filter((csv) => csv);
const rows = [...matchedFileCsvs, unusedCsv, cleanedCsv].filter((csv) => csv);
await util.promisify(fs.writeFile)(report, rows.join('\n'));
this.progressBar.logDebug(`${report}: wrote ${datStatuses.length.toLocaleString()} CSV row${datStatuses.length !== 1 ? 's' : ''}`);

Expand Down
4 changes: 2 additions & 2 deletions src/types/datStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export enum Status {
// The Game wanted to be written, but there was no matching ReleaseCandidate
MISSING,
// The input File was not used in any ReleaseCandidate
UNMATCHED,
UNUSED,
// The output File was not from any ReleaseCandidate, so it was deleted
DELETED,
}
Expand Down Expand Up @@ -79,7 +79,7 @@ export default class DATStatus {
// When running in 1G1R mode, if this Parent has at least one ReleaseCandidate, but no
// matching ReleaseCandidate was found for this Game (above), then report it as IGNORED.
// We can't know if this Game had matching input files, they would have already been
// discarded, so those files will be reported as UNMATCHED.
// discarded, so those files will be reported as UNUSED.
if (options.getSingle() && releaseCandidates.length) {
this.ignoredHashCodesToGames.set(game.hashCode(), game);
}
Expand Down
6 changes: 3 additions & 3 deletions test/modules/reportGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Multiple,Two,FOUND,Two.rom,false,false,true,false,false,false,false,false,false,
});
});

it('should return one row for every unmatched file in a multiple game DAT', async () => {
it('should return one row for every unused file in a multiple game DAT', async () => {
await wrapReportGenerator(new Options(), [
'One.rom',
'Two.rom',
Expand All @@ -153,7 +153,7 @@ Multiple,Five,FOUND,,false,false,true,false,false,false,false,false,false,false,
Multiple,Four,FOUND,Four.rom,false,false,true,false,false,false,false,false,false,false,false,false,false
Multiple,Three,FOUND,Three.rom,false,false,true,false,false,false,false,false,false,false,false,false,false
Multiple,Two,FOUND,Two.rom,false,false,true,false,false,false,false,false,false,false,false,false,false
,,UNMATCHED,One.rom,false,false,false,false,false,false,false,false,false,false,false,false,false`);
,,UNUSED,One.rom,false,false,false,false,false,false,false,false,false,false,false,false,false`);
});
});

Expand All @@ -169,7 +169,7 @@ Multiple,Five,FOUND,,false,false,true,false,false,false,false,false,false,false,
Multiple,Four,FOUND,Four.rom,false,false,true,false,false,false,false,false,false,false,false,false,false
Multiple,Three,FOUND,Three.rom,false,false,true,false,false,false,false,false,false,false,false,false,false
Multiple,Two,FOUND,Two.rom,false,false,true,false,false,false,false,false,false,false,false,false,false
,,UNMATCHED,One.rom,false,false,false,false,false,false,false,false,false,false,false,false,false
,,UNUSED,One.rom,false,false,false,false,false,false,false,false,false,false,false,false,false
,,DELETED,Three.rom,false,false,false,false,false,false,false,false,false,false,false,false,false
,,DELETED,Four.rom,false,false,false,false,false,false,false,false,false,false,false,false,false`);
},
Expand Down

0 comments on commit a9f7353

Please sign in to comment.