Skip to content

Commit

Permalink
refactor(Refined reference table discovery):
Browse files Browse the repository at this point in the history
  • Loading branch information
br648 committed Sep 17, 2024
1 parent 45d7036 commit 40dfe40
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,8 @@ private Table getReferenceTable(FieldContext fieldContext, Field field) {
getTableScopedValue(Table.CALENDAR_DATES, fieldContext.getValue())
);
case STOP_TIMES_STOP_ID_KEY:
return ReferenceTableDiscovery.getStopTimeReferenceTable(
fieldContext.getValueToWrite(),
mergeFeedsResult,
feedMergeContext.locationIds
);
case LOCATION_GROUP_STOPS_STOP_ID_KEY:
return ReferenceTableDiscovery.getLocationGroupStopReferenceTable(
return ReferenceTableDiscovery.getStopReferenceTable(
fieldContext.getValueToWrite(),
mergeFeedsResult
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.conveyal.gtfs.loader.Field;
import com.conveyal.gtfs.loader.Table;

import java.util.Set;
import java.util.stream.Collectors;

import static com.conveyal.datatools.manager.jobs.feedmerge.MergeLineContext.SERVICE_ID;
Expand Down Expand Up @@ -32,18 +31,15 @@ public enum ReferenceTableKey {
REF_TABLE_SEPARATOR,
Table.LOCATION_GROUP_STOPS.name,
"stop_id",
Table.STOPS.name,
Table.LOCATIONS.name
Table.STOPS.name
)
),
STOP_TIMES_STOP_ID_KEY(
String.join(
REF_TABLE_SEPARATOR,
Table.STOP_TIMES.name,
"stop_id",
Table.STOPS.name,
Table.LOCATIONS.name,
Table.LOCATION_GROUP_STOPS.name
Table.STOPS.name
)
);

Expand Down Expand Up @@ -112,33 +108,11 @@ public static Table getTripServiceIdReferenceTable(
}

/**
* Define the reference table for a location group stop: stop id. This will either be a stop or null.
* Defines the reference table as a stop if the field value matches a stop id.
*/
public static Table getLocationGroupStopReferenceTable(
String fieldValue,
MergeFeedsResult mergeFeedsResult
) {
if (mergeFeedsResult.stopIds.contains(fieldValue)) {
return Table.STOPS;
}
return null;
}

/**
* Define the reference table for a stop time's stop id. This will either be a stop, location or location group.
* TODO: In later PR's this will be redundant as a stop time: stop id will only reference a stop.
*/
public static Table getStopTimeReferenceTable(
String fieldValue,
MergeFeedsResult mergeFeedsResult,
Set<String> locationIds
) {
public static Table getStopReferenceTable(String fieldValue, MergeFeedsResult mergeFeedsResult) {
if (mergeFeedsResult.stopIds.contains(fieldValue)) {
return Table.STOPS;
} else if (locationIds.contains(fieldValue)) {
return Table.LOCATIONS;
} else if (mergeFeedsResult.locationGroupStopIds.contains(fieldValue)) {
return Table.LOCATION_GROUP_STOPS;
}
return null;
}
Expand Down

0 comments on commit 40dfe40

Please sign in to comment.