Skip to content

Commit

Permalink
#202: remove commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
mohit-s96 committed Nov 27, 2024
1 parent f24bef1 commit 5cf1742
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 97 deletions.
94 changes: 2 additions & 92 deletions lib/schema/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,101 +424,11 @@ const changeKeyMapToList = errorCache => {
* @param {Object} obj
* @param {{}} obj.errorCache
* @param {{}} obj.warningsCache
* @param {{}} obj.payloadErrors
* @param {{totalWarnings: number, totalErrors: number}} obj.stats
* @param {String} obj.version
* @returns {Object} Consolidated error and warning report
*/
const combineErrors = ({ errorCache, warningsCache, /*payloadErrors*/ stats, version }) => {
// const errorReport = [];

// // Helper function to process either errors or warnings from cache
// const processCache = (cache, type) => {
// Object.entries(cache).forEach(([resource, fields]) => {
// Object.entries(fields).forEach(([fieldName, messages]) => {
// Object.entries(messages).forEach(([, files]) => {
// if (!files) return;

// const occurrences = Object.entries(files).flatMap(([fileName, values]) => {
// const file = path.basename(fileName || '');
// const pathName = fileName;
// return Object.entries(values).map(([lookupValue, details]) => {
// const result = {
// count: details.occurrences,
// message: details.message
// };

// if (file) {
// result.fileName = file;
// }

// if (pathName) {
// result.pathName = pathName;
// }

// if (details?.failedEnum != null) {
// result.lookupValue = lookupValue;
// }

// if (details?.sourceModel) {
// result.sourceModel = details.sourceModel;
// }

// if (details?.sourceModelField) {
// result.sourceModelField = details.sourceModelField;
// }

// if (details?.keyField) {
// result.keyField = details.keyField;
// }

// if (details?.keys) {
// result.keys = details.keys;
// }

// return result;
// });
// });

// const message = occurrences?.[0]?.message ?? '';
// addReport(
// errorReport,
// resource,
// fieldName,
// type,
// message,
// occurrences.map(({ message: _, ...rest }) => rest)
// );
// });
// });
// });
// };

// // Helper function to add error/warning data to errorReport
// const addReport = (report, resource, fieldName, type, message, occurrences) => {
// let fieldData = report.find(x => x.resourceName === resource && x.fieldName === fieldName);
// if (!fieldData) {
// fieldData = { resourceName: resource, fieldName: fieldName, errors: [], warnings: [] };
// report.push(fieldData);
// }
// fieldData[type].push({ message, occurrences });
// };

// // Process errors and warnings
// processCache(errorCache, 'errors');
// processCache(warningsCache, 'warnings');

// // Process payload errors
// Object.entries(payloadErrors).forEach(([resource, messages]) => {
// Object.entries(messages).forEach(([message, files]) => {
// const occurrences = files.map(fileName => ({
// count: 1, // Static count since payload errors are listed individually
// fileName
// }));
// addReport(errorReport, resource, '', 'errors', message, occurrences);
// stats.totalErrors++;
// });
// });

const combineErrors = ({ errorCache, warningsCache, stats, version }) => {
return {
description: 'RESO Common Format Schema Validation Summary',
generatedOn: new Date().toISOString(),
Expand Down
7 changes: 2 additions & 5 deletions lib/schema/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const validate = ({
isResoDataDictionarySchema = false /*CLI only */,
validationConfig = {},
disableKeys,
chunk = true
chunk = false
} = {}) => {
const { stats = { totalErrors: 0, totalWarnings: 0 }, errorCache = {}, warningsCache = {}, payloadErrors = {} } = errorMap;

Expand Down Expand Up @@ -175,9 +175,6 @@ const validate = ({
const validate = ajv.compile(cachedSchema);
console.timeEnd('Compile schema');

// console.time('Chunk payload');
// const chunked = chunkPayload(payload);
// console.timeEnd('Chunk payload');
let chunkedPayload = [payload];
if (chunk) {
chunkedPayload = chunkPayload(payload);
Expand Down Expand Up @@ -345,7 +342,7 @@ const generateErrorReport = ({

let failedItemName = fieldName;
if (params?.additionalProperty) {
if (!!sourceModel) {
if (sourceModel) {
sourceModelField = params?.additionalProperty;
} else {
failedItemName = params?.additionalProperty;
Expand Down

0 comments on commit 5cf1742

Please sign in to comment.