Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NRPT-793: Fixing agri-cmdb outcome description when no issues found #885

Merged
merged 2 commits into from
Jul 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions api/src/importers/cmdb/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CmdbCsvDataSource {
* @param {*} csvRows array of csv row objects to import
* @memberof CmdbCsvDataSource
*/
constructor(taskAuditRecord, auth_payload, recordType, csvRows) {
constructor(taskAuditRecord, auth_payload, recordType, csvRows) {
this.taskAuditRecord = taskAuditRecord;
this.auth_payload = auth_payload;
this.recordType = recordType;
Expand All @@ -27,7 +27,7 @@ class CmdbCsvDataSource {
* @returns final status of importer
* @memberof CmdbCsvDataSource
*/
async run() {
async run() {
defaultLog.info('run - import agri-cmdb-csv');

this.status.itemTotal = this.csvRows.length;
Expand All @@ -46,7 +46,7 @@ class CmdbCsvDataSource {
*
* @memberof CmdbCsvDataSource
*/
async batchProcessRecords() {
async batchProcessRecords() {
try {
const recordTypeConfig = this.getRecordTypeConfig();

Expand Down Expand Up @@ -79,6 +79,10 @@ class CmdbCsvDataSource {
recordOutcomeDescriptions.push(outcomeDescription);
}

if (regulationSection === '' || !regulationSection) {
outcomeDescription = 'No compliance issues identified.';
}

// need to await here because some rows are duplicate records
await this.processRecord(this.csvRows[i], recordTypeConfig, outcomeDescription);

Expand All @@ -91,14 +95,14 @@ class CmdbCsvDataSource {
}
}

/**
* Perform all steps necessary to process and save a single row of the csv file.
*
* @param {*} csvRow object of values for a single row
* @param {*} recordTypeConfig object containing record type specific details
* @memberof CmdbCsvDataSource
*/
async processRecord(csvRow, recordTypeConfig, outcomeDescription = '') {
/**
* Perform all steps necessary to process and save a single row of the csv file.
*
* @param {*} csvRow object of values for a single row
* @param {*} recordTypeConfig object containing record type specific details
* @memberof CmdbCsvDataSource
*/
async processRecord(csvRow, recordTypeConfig, outcomeDescription = '') {
// set status defaults
let recordStatus = {};

Expand Down Expand Up @@ -148,13 +152,13 @@ class CmdbCsvDataSource {
}
}

/**
* Supported Agri csv record type configs.
*
* @returns {*} object with getUtil method to create a new instance of the record type utils.
* @memberof CmdbCsvDataSource
*/
getRecordTypeConfig() {
/**
* Supported Agri csv record type configs.
*
* @returns {*} object with getUtil method to create a new instance of the record type utils.
* @memberof CmdbCsvDataSource
*/
getRecordTypeConfig() {
if (this.recordType === 'Inspection') {
return {
getUtil: (auth_payload, csvRow) => {
Expand Down