Skip to content

Commit 6a77495

Browse files
committed
fix: scope MOTIS config generation to downloaded feed countries
1 parent 6b8f9f2 commit 6a77495

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

infra/docker/services/transitous/fetch-and-configure.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ case "$ACTION" in
2222
fetch)
2323
COUNTRY_FILTER="${1:-}"
2424

25-
# Init Transitland Atlas submodule (needed for resolving feed references)
25+
# Try updating Transitland Atlas submodule (already cloned on host, this is a refresh attempt)
2626
if [ -f .gitmodules ]; then
27-
_blue "[transitous] Initializing Transitland Atlas submodule..."
28-
git submodule update --init --checkout --remote 2>/dev/null || \
29-
_yellow "[!] Could not update Transitland Atlas — using cached version"
27+
git submodule update --init --checkout --remote -q 2>/dev/null || true
3028
fi
3129

3230
# Determine which feed files to process
@@ -86,11 +84,23 @@ case "$ACTION" in
8684

8785
# Run Transitous's config generator (handles RT feed matching, Lua scripts,
8886
# GBFS feeds, protocol mapping, etc.)
89-
ARGS=""
90-
# Skip missing files since not all feeds from catalog may be downloaded
91-
ARGS="$ARGS --skip-missing-files"
87+
ARGS="--skip-missing-files"
88+
89+
# Build region glob patterns from downloaded feeds to avoid processing
90+
# feed files for countries we don't have data for
91+
REGION_GLOBS=()
92+
for f in out/*.gtfs.zip out/*.netex.zip; do
93+
[ -f "$f" ] || continue
94+
local fname
95+
fname=$(basename "$f")
96+
local cc
97+
cc=$(echo "$fname" | sed 's/[_-].*//')
98+
if [ -n "$cc" ] && ! printf '%s\n' "${REGION_GLOBS[@]}" 2>/dev/null | grep -qx "${cc}*"; then
99+
REGION_GLOBS+=("${cc}*")
100+
fi
101+
done
92102

93-
python3 ./src/generate-motis-config.py $ARGS
103+
python3 ./src/generate-motis-config.py $ARGS "${REGION_GLOBS[@]}"
94104

95105
# Count RT feeds in generated config
96106
if [ -f out/config.yml ]; then

0 commit comments

Comments
 (0)