-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
editoast: add field for supported signaling systems in rs model
tests: rolling stock
- Loading branch information
1 parent
472bff2
commit 30d5fe3
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
editoast/migrations/2024-01-17-140850_rollingstock-add-supported-signaling-systems/down.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- This file should undo anything in `up.sql` | ||
|
||
ALTER TABLE rolling_stock | ||
DROP COLUMN supported_signaling_systems; |
16 changes: 16 additions & 0 deletions
16
editoast/migrations/2024-01-17-140850_rollingstock-add-supported-signaling-systems/up.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- Your SQL goes here | ||
|
||
ALTER TABLE rolling_stock | ||
ADD supported_signaling_systems jsonb NOT NULL DEFAULT ('["BAPR", "BAL"]'); | ||
|
||
UPDATE rolling_stock | ||
SET supported_signaling_systems='["BAPR", "BAL", "TVM300"]' | ||
WHERE name IN ('1TGVA','1TGVOSE','1TGVSE','2TGVA','2TGVOSE','2TGVSE'); | ||
|
||
UPDATE rolling_stock | ||
SET supported_signaling_systems='["BAPR", "BAL", "TVM430"]' | ||
WHERE name IN ('1TGVDUPL'); | ||
|
||
UPDATE rolling_stock | ||
SET supported_signaling_systems='["BAPR", "BAL", "TVM300", "TVM430"]' | ||
WHERE name IN ('1PSE300','1TGVPBA','1TGVDASY','2PSE300','2TGVPBA','2TGVDASY','1ICE3','1TGV2N2','1TGVPBKA','1TGVPOS','1TGVR','1TGVR350','1TGVR360','2TGV2N2','2TGVDUPL','2TGVPBKA','2TGVPOS','2TGVR','2TGVR360','BR407 US','BR407UM2','TGVAGT','TMSTEURO','VELARO E'); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import csv | ||
import sys | ||
|
||
def generateRollingStockTvmCompatibilitySql(filename): | ||
with open(filename, newline='') as csvfile: | ||
reader = csv.DictReader(csvfile) | ||
whereClause300 = "WHERE name IN (" | ||
whereClause430 = "WHERE name IN (" | ||
whereClauseBoth = "WHERE name IN (" | ||
for row in reader: | ||
rowCodeEngin = row['Code Engin [Ref]'] | ||
rowTvm300 = row['MR équipé TVM 300 [O, N]'] | ||
rowTvm430 = row['MR équipé TVM 430 [O, N]'] | ||
if rowTvm300 == 'O' and rowTvm430 == 'N': | ||
if len(whereClause300) != 15: | ||
whereClause300 += "," | ||
whereClause300 += f"'{rowCodeEngin}'" | ||
if rowTvm300 == 'N' and rowTvm430 == 'O': | ||
if len(whereClause430) != 15: | ||
whereClause430 += "," | ||
whereClause430 += f"'{rowCodeEngin}'" | ||
if rowTvm300 == 'O' and rowTvm430 == 'O': | ||
if len(whereClauseBoth) != 15: | ||
whereClauseBoth += "," | ||
whereClauseBoth += f"'{rowCodeEngin}'" | ||
|
||
whereClause300 += ");" | ||
whereClause430 += ");" | ||
whereClauseBoth += ");" | ||
print("UPDATE rolling_stock") | ||
print("SET supported_signaling_systems='[\"BAPR\", \"BAL\", \"TVM300\"]'") | ||
print(whereClause300) | ||
print("") | ||
|
||
print("UPDATE rolling_stock") | ||
print("SET supported_signaling_systems='[\"BAPR\", \"BAL\", \"TVM430\"]'") | ||
print(whereClause430) | ||
print("") | ||
|
||
print("UPDATE rolling_stock") | ||
print("SET supported_signaling_systems='[\"BAPR\", \"BAL\", \"TVM300\", \"TVM430\"]'") | ||
print(whereClauseBoth) | ||
print("") | ||
|
||
def main(): | ||
if len(sys.argv) > 1: | ||
input_string = sys.argv[1] | ||
generateRollingStockTvmCompatibilitySql(input_string) | ||
else: | ||
print("Please provide csv filename") | ||
|
||
if __name__ == "__main__": | ||
main() |