forked from TDTP/admin_transporte_backend
Agrega Validaciones a Carga GTFS y define rutas de informes
parent
d786071f9e
commit
4ae2ef977e
|
@ -92,6 +92,28 @@ BEGIN
|
|||
|
||||
if v_error = '' THEN
|
||||
|
||||
/* ASEGURA QUE CADA TRIPS TENGA UN SOLO GUION EN SU DESCRIPCION */
|
||||
UPDATE z_trips
|
||||
SET trip_headsign =
|
||||
CASE
|
||||
WHEN (LENGTH(trip_headsign) - LENGTH(REPLACE(trip_headsign, '-', '')) = 2) THEN
|
||||
regexp_replace(trip_headsign, '^(.*)-(.*)-(.*)$', '\1-\2~\3')
|
||||
ELSE
|
||||
trip_headsign
|
||||
end
|
||||
WHERE trip_headsign LIKE '%-%-%';
|
||||
|
||||
update z_routes
|
||||
set route_long_name = replace (route_long_name,replace(
|
||||
(select distinct trip_headsign from z_trips where route_id =z_routes.route_id and trip_headsign like '%~%' ),'~','-'
|
||||
),
|
||||
(select distinct trip_headsign from z_trips where route_id =z_routes.route_id and trip_headsign like '%~%' )
|
||||
)
|
||||
WHERE route_long_name LIKE '%-%-%-%-%';
|
||||
|
||||
|
||||
|
||||
|
||||
update gtfs_archivo
|
||||
set vigente = False
|
||||
where vigente = true and id_red in
|
||||
|
@ -351,8 +373,29 @@ if v_error = '' THEN
|
|||
where id_comuna is null;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS gtfs_validaciones (
|
||||
id_gtfs int4 not null,
|
||||
route_id text NULL,
|
||||
route_long_name text NULL,
|
||||
observacion text NULL
|
||||
);
|
||||
|
||||
|
||||
insert into gtfs_validaciones
|
||||
select (select id_gtfs from gtfs_archivo where trim(upper(status))='PROCESANDO' ),
|
||||
route_id, route_long_name,
|
||||
'Ruta sin Trips Asociados'
|
||||
from z_routes
|
||||
where route_id not in
|
||||
(select route_id from z_trips ) ;
|
||||
|
||||
|
||||
update gtfs_archivo
|
||||
set vigente = true , status = 'GTFS CARGADO'
|
||||
set vigente = true , status = case when
|
||||
(
|
||||
select count(*) from gtfs_validaciones where id_gtfs =(select id_gtfs from gtfs_archivo where trim(upper(status))='PROCESANDO' )
|
||||
) =0 then 'GTFS CARGADO' else 'GTFS CARGADO CON REPAROS' END
|
||||
where trim(upper(status))='PROCESANDO' ;
|
||||
|
||||
END IF;
|
||||
|
|
|
@ -131,7 +131,7 @@ def procesa_tablas_z(cursor):
|
|||
with open(os.path.join(current_folder, 'actualiza_GTFS.sql'),'r') as file:
|
||||
sqlFile = file.read()
|
||||
cursor.execute(sqlFile)
|
||||
cursor.commit()
|
||||
#cursor.commit()
|
||||
""" content = ''.join(file.readlines())
|
||||
|
||||
arr_sql = content.split('-----')
|
||||
|
|
Loading…
Reference in New Issue