Skip to content

Commit

Permalink
Merge branch '177-ignored-items-not-working-with-expansions' into 102…
Browse files Browse the repository at this point in the history
…-create-reports-for-reso-common-format-testing
  • Loading branch information
mohit-s96 committed Sep 26, 2024
2 parents bc79461 + 76a3479 commit a3f9fb0
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/schema/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ const addPrefixToFileName = (fileName, prefix) => {
return `${prefix}__${fileName}`;
};

const removeFilenamePrefix = fileName => {
const parts = fileName.split('__');
if (parts.length > 1) {
return parts.slice(1).join('__');
}
return fileName;
};

/**
* @param {Object} obj
* @param {string} obj.inputPath
Expand Down Expand Up @@ -475,6 +483,7 @@ const updateCacheAndStats = ({
sourceModel,
sourceModelField
}) => {
const originalFilename = removeFilenamePrefix(fileName);
if (!cache[resourceName]) {
cache[resourceName] = {};
}
Expand All @@ -487,12 +496,12 @@ const updateCacheAndStats = ({
cache[resourceName][failedItemName][message] = {};
}

if (!cache[resourceName][failedItemName][message][fileName]) {
cache[resourceName][failedItemName][message][fileName] = {};
if (!cache[resourceName][failedItemName][message][originalFilename]) {
cache[resourceName][failedItemName][message][originalFilename] = {};
}

if (!cache[resourceName][failedItemName][message][fileName][failedItemValue]) {
cache[resourceName][failedItemName][message][fileName][failedItemValue] = {
if (!cache[resourceName][failedItemName][message][originalFilename][failedItemValue]) {
cache[resourceName][failedItemName][message][originalFilename][failedItemValue] = {
// Capitalize first word like MUST, SHOULD, etc.
message: !message.startsWith(isWarning ? 'The' : 'Fields')
? message.slice(0, message.indexOf(' ')).toUpperCase() + message.slice(message.indexOf(' '), message.length)
Expand All @@ -502,7 +511,7 @@ const updateCacheAndStats = ({
sourceModelField
};
} else {
cache[resourceName][failedItemName][message][fileName][failedItemValue].occurrences++;
cache[resourceName][failedItemName][message][originalFilename][failedItemValue].occurrences++;
}

if (isWarning) {
Expand Down

0 comments on commit a3f9fb0

Please sign in to comment.