Skip to content

Commit

Permalink
editoast: add field for supported signaling systems in rs model
Browse files Browse the repository at this point in the history
tests: rolling stock
  • Loading branch information
SarahBellaha committed Feb 2, 2024
1 parent 472bff2 commit 30d5fe3
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
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;
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');
55 changes: 55 additions & 0 deletions scripts/generate-migration-tvm.py
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()

0 comments on commit 30d5fe3

Please sign in to comment.