-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from guardian/pf/experiment-category-mappings…
…-in-ui Add experimental subjects lookup for debugging
- Loading branch information
Showing
3 changed files
with
6,846 additions
and
1 deletion.
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
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,28 @@ | ||
import { lookupTables } from './category-code-lookup-tables'; | ||
|
||
const qCodePrefixesLookup = { | ||
medtop: ['IPTC MediaTopics'], | ||
subj: ['IPTC NewsCodes', 'IPTC MediaTopics'], | ||
a1312cat: ['A1312 CatCodes'], | ||
n2000: ['N2000 Codes'], | ||
n2: ['N2000 Codes'], | ||
}; | ||
|
||
export function lookupCatCodesWideSearch(catCode: string): string[] { | ||
return lookupTables | ||
.map((table) => { | ||
if (table.lookup[catCode]) { | ||
return `${table.lookup[catCode]} (${table.name})`; | ||
} | ||
if (table.lookup[catCode.toUpperCase()]) { | ||
return `${table.lookup[catCode.toUpperCase()]} (${table.name})`; | ||
} | ||
if (table.lookup[catCode.toLowerCase()]) { | ||
return `${table.lookup[catCode.toLowerCase()]} (${table.name})`; | ||
} | ||
if (catCode.includes(':') && table.lookup[catCode.split(':')[1]]) { | ||
return `${table.lookup[catCode.split(':')[1]]} (${table.name})`; | ||
} | ||
}) | ||
.filter((item): item is string => !!item); | ||
} |
Oops, something went wrong.