Created
April 21, 2020 15:50
-
-
Save justin-lyon/6cf483d7c9c34f0c76fa89005f11e907 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public class CSVQueueable implements Queueable, Database.AllowsCallouts { | |
// Read in the CSV to a List<CSVRow> | |
// Persist the execution state across Async Queuable and Batch | |
private CSVState state; | |
// Count of Unique Policy Numbers to aggregate from the CSV | |
private Integer csvChunkSize; | |
public CSVQueueable (CSVState state) { | |
this(state, 1000); | |
} | |
public CSVQueueable (CSVState state, Integer chunkSize) { | |
this.state = state; | |
this.csvChunkSize = chunkSize; | |
} | |
public void execute (BatchableContext ctx) { | |
state.next(); // read the next 1000 unique policy numbers from the csv | |
state.getInProcessing() // => Set<String> policyNumbers | |
// Batch QueryLocator to process FROM Policy WHERE PolicyNumber IN state.getInProgress() | |
Database.executeBatch(new CSVBatch(state)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment