Skip to content

Commit 353f2de

Browse files
Perform database changes after file changes
`getSingleCutoffGrid` can be run more than once on the same inputs. We should perform the database changes after all of the files are generated in case there is an error during one of the runs so that we could just run this again if needed.
1 parent 0ba43b0 commit 353f2de

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/java/com/conveyal/analysis/GenerateRegionalAnalysisResults.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,12 @@ public void action(ProgressListener progressListener) throws Exception {
4646
int[] cutoffs = Objects.requireNonNullElseGet(regionalAnalysis.cutoffsMinutes, () -> new int[]{regionalAnalysis.cutoffMinutes});
4747
String[] destinationPointSetIds = Objects.requireNonNullElseGet(regionalAnalysis.destinationPointSetIds, () -> new String[]{regionalAnalysis.grid});
4848

49-
// Save as modern types
50-
regionalAnalysis.cutoffsMinutes = cutoffs;
51-
regionalAnalysis.travelTimePercentiles = percentiles;
52-
regionalAnalysis.destinationPointSetIds = destinationPointSetIds;
53-
Persistence.regionalAnalyses.put(regionalAnalysis);
54-
5549
// Iterate through all values and generate all possible formats for them.
5650
for (String destinationPointSetId : destinationPointSetIds) {
5751
OpportunityDataset destinations = Persistence.opportunityDatasets.get(destinationPointSetId);
5852
for (int cutoffMinutes : cutoffs) {
5953
for (int percentile : percentiles) {
6054
for (FileStorageFormat format : validFormats) {
61-
filesGenerated++;
6255
RegionalAnalysisController.getSingleCutoffGrid(
6356
fileStorage,
6457
regionalAnalysis,
@@ -67,11 +60,18 @@ public void action(ProgressListener progressListener) throws Exception {
6760
percentile,
6861
format
6962
);
63+
filesGenerated++;
7064
}
7165
}
7266
}
7367
}
7468

69+
// Save as modern types
70+
regionalAnalysis.cutoffsMinutes = cutoffs;
71+
regionalAnalysis.travelTimePercentiles = percentiles;
72+
regionalAnalysis.destinationPointSetIds = destinationPointSetIds;
73+
Persistence.regionalAnalyses.put(regionalAnalysis);
74+
7575
LOG.info("Finished processing {} of {}.", regionalAnalysis._id, regionalAnalysis.accessGroup);
7676
}
7777
} catch (Exception e) {

0 commit comments

Comments
 (0)