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

Removing "total" from RD Migration JSON to free up space in field #6824

Merged
merged 12 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ public abstract class RD2_DataMigrationBase_BATCH implements Database.Batchable<
*/
public void finish(Database.BatchableContext context) {
UTIL_BatchJobService.JobSummary summary = new UTIL_BatchJobService.JobSummary(batchJobId)
.withTotalRecords(totalRecords)
.withTotalRecordsProcessed(totalRecords - totalRecordsFailed)
.withTotalRecordsFailed(totalRecordsFailed)
.withCompletedDate(Datetime.now());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,14 @@ private with sharing class RD2_DataMigrationEnablement_TEST {
Boolean isDryRunMode = false;
UTIL_BatchJobService.JobSummary summary =
new UTIL_BatchJobService.JobSummary(BATCH_ID)
.withTotalRecords(2)
.withTotalRecordsProcessed(2);

batchJob.saveSummary(summary, isDryRunMode);

summary = batchJob.getSummary(BATCH_ID, MIGRATION_BATCH_CLASS);
System.assertNotEquals(null, summary, 'Summary should be returned');
System.assertEquals(BATCH_ID, summary.batchId, 'Batch Id should match: ' + summary);
System.assertEquals(2, summary.total, 'Total records should match: ' + summary);
System.assertEquals(2, summary.processed, 'Processed records should match: ' + summary);

summary = batchJob.getSummary(BATCH_ID, DRY_RUN_MIGRATION_BATCH_CLASS);
System.assertEquals(null, summary, 'Summary should not exist for dry run');
Expand All @@ -73,7 +72,6 @@ private with sharing class RD2_DataMigrationEnablement_TEST {
Boolean isDryRunMode = true;
UTIL_BatchJobService.JobSummary summary =
new UTIL_BatchJobService.JobSummary(BATCH_ID)
.withTotalRecords(2)
.withTotalRecordsProcessed(2)
.withCompletedDate(MIGRATION_TIME);

Expand All @@ -82,7 +80,7 @@ private with sharing class RD2_DataMigrationEnablement_TEST {
summary = batchJob.getSummary(BATCH_ID, DRY_RUN_MIGRATION_BATCH_CLASS);
System.assertNotEquals(null, summary, 'Summary should be returned');
System.assertEquals(BATCH_ID, summary.batchId, 'Batch Id should match: ' + summary);
System.assertEquals(2, summary.total, 'Total records should match: ' + summary);
System.assertEquals(2, summary.processed, 'Processed records should match: ' + summary);
System.assertEquals(MIGRATION_TIME, summary.completedDate, 'Completed time shhould match: ' + summary);

summary = batchJob.getSummary(BATCH_ID, MIGRATION_BATCH_CLASS);
Expand Down
4 changes: 0 additions & 4 deletions force-app/main/default/classes/RD2_DataMigration_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,6 @@ private class RD2_DataMigration_TEST {

UTIL_BatchJobService.JobSummary expectedSummary =
new UTIL_BatchJobService.JobSummary(jobId)
.withTotalRecords(2)
.withTotalRecordsProcessed(1)
.withTotalRecordsFailed(1);

Expand Down Expand Up @@ -2399,7 +2398,6 @@ private class RD2_DataMigration_TEST {
private static void assertBatchSummarySuccess(Id jobId, Integer totalProcessed) {
UTIL_BatchJobService.JobSummary expectedSummary =
new UTIL_BatchJobService.JobSummary(jobId)
.withTotalRecords(totalProcessed)
.withTotalRecordsProcessed(totalProcessed)
.withTotalRecordsFailed(0);

Expand All @@ -2415,7 +2413,6 @@ private class RD2_DataMigration_TEST {
private static void assertBatchSummaryFailed(Id jobId, Integer totalFailed) {
UTIL_BatchJobService.JobSummary expectedSummary =
new UTIL_BatchJobService.JobSummary(jobId)
.withTotalRecords(totalFailed)
.withTotalRecordsProcessed(0)
.withTotalRecordsFailed(totalFailed);

Expand All @@ -2437,7 +2434,6 @@ private class RD2_DataMigration_TEST {

UTIL_BatchJobService.JobSummary summary = summaryByType.values()[0];
System.assertEquals(expectedSummary.batchId, summary.batchId, 'Batch Id should match: ' + summary);
System.assertEquals(expectedSummary.total, summary.total, 'Total Records should match: ' + summary);
System.assertEquals(expectedSummary.processed, summary.processed, 'Total Records Processed should match: ' + summary);
System.assertEquals(expectedSummary.failed, summary.failed, 'Total Records Failed should match: ' + summary);
}
Expand Down
4 changes: 0 additions & 4 deletions force-app/main/default/classes/STG_SettingsManager_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1961,7 +1961,6 @@ private with sharing class STG_SettingsManager_TEST {
RD2_EnablementService_TEST.setRecurringDonations2Enabled();

UTIL_BatchJobService.JobSummary summary = new UTIL_BatchJobService.JobSummary(UTIL_BatchJobService_TEST.MOCK_BATCH_ID)
.withTotalRecords(2)
.withTotalRecordsProcessed(2);

Map<String, UTIL_BatchJobService.JobSummary> summaryByType = new Map<String, UTIL_BatchJobService.JobSummary> {
Expand Down Expand Up @@ -1990,7 +1989,6 @@ private with sharing class STG_SettingsManager_TEST {
RD2_EnablementService_TEST.setRecurringDonations2Enabled();

UTIL_BatchJobService.JobSummary summary = new UTIL_BatchJobService.JobSummary(UTIL_BatchJobService_TEST.MOCK_BATCH_ID)
.withTotalRecords(2)
.withTotalRecordsProcessed(2);

Map<String, UTIL_BatchJobService.JobSummary> summaryByType = new Map<String, UTIL_BatchJobService.JobSummary> {
Expand Down Expand Up @@ -2023,7 +2021,6 @@ private with sharing class STG_SettingsManager_TEST {
RD2_EnablementService_TEST.setRecurringDonations2Enabled();

UTIL_BatchJobService.JobSummary summary = new UTIL_BatchJobService.JobSummary(UTIL_BatchJobService_TEST.MOCK_BATCH_ID)
.withTotalRecords(2)
.withTotalRecordsProcessed(2);

Map<String, UTIL_BatchJobService.JobSummary> summaryByType = new Map<String, UTIL_BatchJobService.JobSummary> {
Expand Down Expand Up @@ -2055,7 +2052,6 @@ private with sharing class STG_SettingsManager_TEST {
RD2_EnablementService_TEST.setRecurringDonations2Enabled();

UTIL_BatchJobService.JobSummary summary = new UTIL_BatchJobService.JobSummary(UTIL_BatchJobService_TEST.MOCK_BATCH_ID)
.withTotalRecords(2)
.withTotalRecordsProcessed(2);

Map<String, UTIL_BatchJobService.JobSummary> summaryByType = new Map<String, UTIL_BatchJobService.JobSummary> {
Expand Down
11 changes: 0 additions & 11 deletions force-app/main/default/classes/UTIL_BatchJobService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ public without sharing class UTIL_BatchJobService {
*/
public class JobSummary {
public Id batchId;
public Integer total = 0;
public Integer processed = 0;
public Integer failed = 0;
public Datetime completedDate;
Expand All @@ -475,16 +474,6 @@ public without sharing class UTIL_BatchJobService {
this.batchId = batchId;
}

/**
* @description Sets number of records selected
* @param total Number of records selected
* @return JobSummary
*/
public JobSummary withTotalRecords(Integer total) {
this.total = total;
return this;
}

/**
* @description Sets number of records processed
* @param processed Number of records processed
Expand Down
3 changes: 0 additions & 3 deletions force-app/main/default/classes/UTIL_BatchJobService_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,11 @@ public with sharing class UTIL_BatchJobService_TEST {

UTIL_BatchJobService.JobSummary summary =
new UTIL_BatchJobService.JobSummary(MOCK_BATCH_ID)
.withTotalRecords(total)
.withTotalRecordsProcessed(processed)
.withTotalRecordsFailed(failed)
.withCompletedDate(completedTime);

System.assertEquals(MOCK_BATCH_ID, summary.batchId, 'Batch Id should match');
System.assertEquals(total, summary.total, 'Total Records should match');
System.assertEquals(processed, summary.processed, 'Total Records Processed should match');
System.assertEquals(failed, summary.failed, 'Total Records Failed should match');
System.assertEquals(completedTime, summary.completedDate, 'Completed Date should match');
Expand Down Expand Up @@ -266,7 +264,6 @@ public with sharing class UTIL_BatchJobService_TEST {
System.assertNotEquals(null, batchJob.summary, 'Batch Job summary should be returned');

System.assertEquals(jobId, batchJob.summary.batchId, 'Batch Id should match: ' + batchJob.summary);
System.assertEquals(1, batchJob.summary.total, 'Total Records should match: ' + batchJob.summary);
System.assertEquals(1, batchJob.summary.processed, 'Total Records Processed should match: ' + batchJob.summary);
System.assertEquals(0, batchJob.summary.failed, 'Total Records Failed should match: ' + batchJob.summary);
System.assertNotEquals(null, batchJob.summary.completedDate, 'The completed time should be stored');
Expand Down
9 changes: 9 additions & 0 deletions force-app/main/default/lwc/batchProgress/batchProgress.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export default class BatchProgress extends LightningElement {

this.hasSummary = !isNull(this.batchJob.summary);

this.setTotalRecords();

this.notifyOnStatusChange();

if (this.batchJob.isInProgress === true
Expand All @@ -96,6 +98,13 @@ export default class BatchProgress extends LightningElement {
}, this.pollingTimeout, self);
}

/***
* @description Sets the Total Records value based on Processed and Failed
*/
setTotalRecords() {
this.batchJob.summary.total = this.batchJob.summary.processed + this.batchJob.summary.failed;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd change this up a tiny bit to add that total property on to the object before assigning it to this.batchJob. Here's a suggestion below:

Suggested change
setTotalRecords() {
this.batchJob.summary.total = this.batchJob.summary.processed + this.batchJob.summary.failed;
}
setTotalRecords(data) {
if(!isNull(data)) {
data.summary.total = data.summary.processed + data.summary.failed;
return data;
}
return null;
}

Then with that, we could do something like:

this.batchJob = setTotalRecords(JSON.parse(data));


/***
* @description Notifies other components about the batch status change
*/
Expand Down