Skip to content

Commit

Permalink
fix(MergeFeedsJob): fix end_date update on merge
Browse files Browse the repository at this point in the history
fix #306
  • Loading branch information
landonreed committed May 5, 2020
1 parent 3a10fba commit 1c3c1ca
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,9 @@ private int constructMergedTable(Table table, List<FeedToMerge> feedsToMerge,
// Get index of field from GTFS spec as it appears in feed
int index = fieldsFoundList.indexOf(field);
String val = csvReader.get(index);
// Default value to write is unchanged from value found in csv.
// Default value to write is unchanged from value found in csv (i.e. val). Note: if looking to
// modify the value that is written in the merged file, you must update valueToWrite (e.g.,
// updating the current feed's end_date or accounting for cases where IDs conflict).
String valueToWrite = val;
// Handle filling in agency_id if missing when merging regional feeds.
if (newAgencyId != null && field.name.equals("agency_id") && mergeType
Expand Down Expand Up @@ -615,10 +617,9 @@ private int constructMergedTable(Table table, List<FeedToMerge> feedsToMerge,
getFieldIndex(fieldsFoundInZip, "end_date");
if (index == endDateIndex) {
LocalDate endDate = LocalDate
.parse(csvReader.get(endDateIndex),
GTFS_DATE_FORMATTER);
.parse(csvReader.get(endDateIndex), GTFS_DATE_FORMATTER);
if (!endDate.isBefore(futureFeedFirstDate)) {
val = futureFeedFirstDate
val = valueToWrite = futureFeedFirstDate
.minus(1, ChronoUnit.DAYS)
.format(GTFS_DATE_FORMATTER);
}
Expand Down

0 comments on commit 1c3c1ca

Please sign in to comment.