diff --git a/rj_cor/meteorologia/precipitacao_alertario/flows.html b/rj_cor/meteorologia/precipitacao_alertario/flows.html index e6ca7ce89..c28b0f384 100644 --- a/rj_cor/meteorologia/precipitacao_alertario/flows.html +++ b/rj_cor/meteorologia/precipitacao_alertario/flows.html @@ -35,6 +35,7 @@

Module pipelines.rj_cor.meteorologia.precipitacao_alerta from datetime import timedelta from prefect import case, Parameter +from prefect.executors import LocalDaskExecutor from prefect.run_configs import KubernetesRun from prefect.storage import GCS from prefect.tasks.prefect import create_flow_run, wait_for_flow_run @@ -238,6 +239,7 @@

Module pipelines.rj_cor.meteorologia.precipitacao_alerta image=constants.DOCKER_IMAGE.value, labels=[constants.RJ_COR_AGENT_LABEL.value], ) +cor_meteorologia_precipitacao_alertario.executor = LocalDaskExecutor(num_workers=10) cor_meteorologia_precipitacao_alertario.schedule = minute_schedule diff --git a/rj_escritorio/rain_dashboard/constants.html b/rj_escritorio/rain_dashboard/constants.html index 41e90bf5f..53f8a7d68 100644 --- a/rj_escritorio/rain_dashboard/constants.html +++ b/rj_escritorio/rain_dashboard/constants.html @@ -66,49 +66,49 @@

Module pipelines.rj_escritorio.rain_dashboard.constants< WHERE a.row_num = 1 ), - websirene AS ( -- seleciona a última medição do websirene de cada estação nos últimos 30min - SELECT - id_estacao, - acumulado_chuva_15_min, - CURRENT_DATE('America/Sao_Paulo') as data, - data_update - FROM ( - SELECT - id_estacao, - acumulado_chuva_15_min, - data_particao, - DATETIME(CONCAT(data_particao," ", horario)) AS data_update, - ROW_NUMBER() OVER ( - PARTITION BY id_estacao ORDER BY DATETIME(CONCAT(data_particao," ", horario)) DESC - ) AS row_num - FROM `rj-cor.clima_pluviometro.taxa_precipitacao_websirene` - WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 1 DAY) - AND horario >= TIME_SUB(CURRENT_TIME('America/Sao_Paulo'), INTERVAL 30 MINUTE) - )AS a - WHERE a.row_num = 1 - ), + -- websirene AS ( -- seleciona a última medição do websirene de cada estação nos últimos 30min + -- SELECT + -- id_estacao, + -- acumulado_chuva_15_min, + -- CURRENT_DATE('America/Sao_Paulo') as data, + -- data_update + -- FROM ( + -- SELECT + -- id_estacao, + -- acumulado_chuva_15_min, + -- data_particao, + -- DATETIME(CONCAT(data_particao," ", horario)) AS data_update, + -- ROW_NUMBER() OVER ( + -- PARTITION BY id_estacao ORDER BY DATETIME(CONCAT(data_particao," ", horario)) DESC + -- ) AS row_num + -- FROM `rj-cor.clima_pluviometro.taxa_precipitacao_websirene` + -- WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 1 DAY) + -- AND horario >= TIME_SUB(CURRENT_TIME('America/Sao_Paulo'), INTERVAL 30 MINUTE) + -- )AS a + -- WHERE a.row_num = 1 + -- ), - cemaden AS ( -- seleciona a última medição do cemaden de cada estação nos últimos 30min - SELECT - id_estacao, - acumulado_chuva_10_min AS acumulado_chuva_15_min, - CURRENT_DATE('America/Sao_Paulo') as data, - data_update - FROM ( - SELECT - id_estacao, - acumulado_chuva_10_min, - data_particao, - DATETIME(data_medicao) AS data_update, - ROW_NUMBER() OVER ( - PARTITION BY id_estacao ORDER BY DATETIME(data_medicao) DESC - ) AS row_num - FROM `rj-cor.clima_pluviometro.taxa_precipitacao_cemaden` - WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 1 DAY) - AND data_medicao >= TIMESTAMP_SUB(CURRENT_DATETIME('America/Sao_Paulo'), INTERVAL 30 MINUTE) - )AS a - WHERE a.row_num = 1 - ), + -- cemaden AS ( -- seleciona a última medição do cemaden de cada estação nos últimos 30min + -- SELECT + -- id_estacao, + -- acumulado_chuva_10_min AS acumulado_chuva_15_min, + -- CURRENT_DATE('America/Sao_Paulo') as data, + -- data_update + -- FROM ( + -- SELECT + -- id_estacao, + -- acumulado_chuva_10_min, + -- data_particao, + -- DATETIME(data_medicao) AS data_update, + -- ROW_NUMBER() OVER ( + -- PARTITION BY id_estacao ORDER BY DATETIME(data_medicao) DESC + -- ) AS row_num + -- FROM `rj-cor.clima_pluviometro.taxa_precipitacao_cemaden` + -- WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 1 DAY) + -- AND data_medicao >= TIMESTAMP_SUB(CURRENT_DATETIME('America/Sao_Paulo'), INTERVAL 30 MINUTE) + -- )AS a + -- WHERE a.row_num = 1 + -- ), last_measurements AS (-- concatena medições do alertario, cemaden e websirene (SELECT @@ -117,20 +117,20 @@

Module pipelines.rj_escritorio.rain_dashboard.constants< "alertario" AS sistema, acumulado_chuva_15_min, FROM alertario) - UNION ALL - (SELECT - id_estacao, - data_update, - "websirene" AS sistema, - acumulado_chuva_15_min, - FROM websirene) - UNION ALL - (SELECT - id_estacao, - data_update, - "cemaden" AS sistema, - acumulado_chuva_15_min, - FROM cemaden) + -- UNION ALL + -- (SELECT + -- id_estacao, + -- data_update, + -- "websirene" AS sistema, + -- acumulado_chuva_15_min, + -- FROM websirene) + -- UNION ALL + -- (SELECT + -- id_estacao, + -- data_update, + -- "cemaden" AS sistema, + -- acumulado_chuva_15_min, + -- FROM cemaden) ), h3_chuvas AS ( -- calcula qnt de chuva para cada h3 @@ -156,22 +156,22 @@

Module pipelines.rj_escritorio.rain_dashboard.constants< ST_GEOGPOINT(CAST(longitude AS FLOAT64), CAST(latitude AS FLOAT64)) AS geom FROM `rj-cor.clima_pluviometro.estacoes_alertario`) - UNION ALL - (SELECT - id_estacao AS id, - estacao, - "websirene" AS sistema, - ST_GEOGPOINT(CAST(longitude AS FLOAT64), - CAST(latitude AS FLOAT64)) AS geom - FROM `rj-cor.clima_pluviometro.estacoes_websirene`) - UNION ALL - (SELECT - id_estacao AS id, - estacao, - "cemaden" AS sistema, - ST_GEOGPOINT(CAST(longitude AS FLOAT64), - CAST(latitude AS FLOAT64)) AS geom - FROM `rj-cor.clima_pluviometro.estacoes_cemaden`) + -- UNION ALL + -- (SELECT + -- id_estacao AS id, + -- estacao, + -- "websirene" AS sistema, + -- ST_GEOGPOINT(CAST(longitude AS FLOAT64), + -- CAST(latitude AS FLOAT64)) AS geom + -- FROM `rj-cor.clima_pluviometro.estacoes_websirene`) + -- UNION ALL + -- (SELECT + -- id_estacao AS id, + -- estacao, + -- "cemaden" AS sistema, + -- ST_GEOGPOINT(CAST(longitude AS FLOAT64), + -- CAST(latitude AS FLOAT64)) AS geom + -- FROM `rj-cor.clima_pluviometro.estacoes_cemaden`) ), estacoes_mais_proximas AS ( @@ -247,10 +247,10 @@

Module pipelines.rj_escritorio.rain_dashboard.constants< ELSE 'sem chuva' END AS status, CASE - WHEN chuva_15min> 0 AND chuva_15min<= 1.25 THEN '#DAECFB'--'#00CCFF' - WHEN chuva_15min> 1.25 AND chuva_15min<= 6.25 THEN '#A9CBE8'--'#BFA230' - WHEN chuva_15min> 6.25 AND chuva_15min<= 12.5 THEN '#77A9D5'--'#E0701F' - WHEN chuva_15min> 12.5 THEN '#125999'--'#FF0000' + WHEN chuva_15min> 0 AND chuva_15min<= 1.25 THEN '#DAECFB' + WHEN chuva_15min> 1.25 AND chuva_15min<= 6.25 THEN '#A9CBE8' + WHEN chuva_15min> 6.25 AND chuva_15min<= 12.5 THEN '#77A9D5' + WHEN chuva_15min> 12.5 THEN '#125999' ELSE '#ffffff' END AS color FROM final_table @@ -268,26 +268,26 @@

Module pipelines.rj_escritorio.rain_dashboard.constants< WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 2 DAY) AND CAST(CONCAT(data_particao, " ", horario) AS DATETIME) <= CURRENT_DATETIME('America/Sao_Paulo') ) - UNION ALL - ( - SELECT - MAX( - DATETIME( - CONCAT(data_particao," ", horario) - ) - ) AS last_update - FROM `rj-cor.clima_pluviometro.taxa_precipitacao_websirene` - WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 2 DAY) - AND CAST(CONCAT(data_particao, " ", horario) AS DATETIME) <= CURRENT_DATETIME('America/Sao_Paulo') - ) - UNION ALL - ( - SELECT - MAX(DATETIME(data_medicao)) AS last_update - FROM `rj-cor.clima_pluviometro.taxa_precipitacao_cemaden` - WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 2 DAY) - AND data_medicao <= CURRENT_DATETIME('America/Sao_Paulo') - ) + -- UNION ALL + -- ( + -- SELECT + -- MAX( + -- DATETIME( + -- CONCAT(data_particao," ", horario) + -- ) + -- ) AS last_update + -- FROM `rj-cor.clima_pluviometro.taxa_precipitacao_websirene` + -- WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 2 DAY) + -- AND CAST(CONCAT(data_particao, " ", horario) AS DATETIME) <= CURRENT_DATETIME('America/Sao_Paulo') + -- ) + -- UNION ALL + -- ( + -- SELECT + -- MAX(DATETIME(data_medicao)) AS last_update + -- FROM `rj-cor.clima_pluviometro.taxa_precipitacao_cemaden` + -- WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 2 DAY) + -- AND data_medicao <= CURRENT_DATETIME('America/Sao_Paulo') + -- ) ) SELECT MAX(last_update) AS last_update @@ -346,49 +346,49 @@

Classes

WHERE a.row_num = 1 ), - websirene AS ( -- seleciona a última medição do websirene de cada estação nos últimos 30min - SELECT - id_estacao, - acumulado_chuva_15_min, - CURRENT_DATE('America/Sao_Paulo') as data, - data_update - FROM ( - SELECT - id_estacao, - acumulado_chuva_15_min, - data_particao, - DATETIME(CONCAT(data_particao," ", horario)) AS data_update, - ROW_NUMBER() OVER ( - PARTITION BY id_estacao ORDER BY DATETIME(CONCAT(data_particao," ", horario)) DESC - ) AS row_num - FROM `rj-cor.clima_pluviometro.taxa_precipitacao_websirene` - WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 1 DAY) - AND horario >= TIME_SUB(CURRENT_TIME('America/Sao_Paulo'), INTERVAL 30 MINUTE) - )AS a - WHERE a.row_num = 1 - ), + -- websirene AS ( -- seleciona a última medição do websirene de cada estação nos últimos 30min + -- SELECT + -- id_estacao, + -- acumulado_chuva_15_min, + -- CURRENT_DATE('America/Sao_Paulo') as data, + -- data_update + -- FROM ( + -- SELECT + -- id_estacao, + -- acumulado_chuva_15_min, + -- data_particao, + -- DATETIME(CONCAT(data_particao," ", horario)) AS data_update, + -- ROW_NUMBER() OVER ( + -- PARTITION BY id_estacao ORDER BY DATETIME(CONCAT(data_particao," ", horario)) DESC + -- ) AS row_num + -- FROM `rj-cor.clima_pluviometro.taxa_precipitacao_websirene` + -- WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 1 DAY) + -- AND horario >= TIME_SUB(CURRENT_TIME('America/Sao_Paulo'), INTERVAL 30 MINUTE) + -- )AS a + -- WHERE a.row_num = 1 + -- ), - cemaden AS ( -- seleciona a última medição do cemaden de cada estação nos últimos 30min - SELECT - id_estacao, - acumulado_chuva_10_min AS acumulado_chuva_15_min, - CURRENT_DATE('America/Sao_Paulo') as data, - data_update - FROM ( - SELECT - id_estacao, - acumulado_chuva_10_min, - data_particao, - DATETIME(data_medicao) AS data_update, - ROW_NUMBER() OVER ( - PARTITION BY id_estacao ORDER BY DATETIME(data_medicao) DESC - ) AS row_num - FROM `rj-cor.clima_pluviometro.taxa_precipitacao_cemaden` - WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 1 DAY) - AND data_medicao >= TIMESTAMP_SUB(CURRENT_DATETIME('America/Sao_Paulo'), INTERVAL 30 MINUTE) - )AS a - WHERE a.row_num = 1 - ), + -- cemaden AS ( -- seleciona a última medição do cemaden de cada estação nos últimos 30min + -- SELECT + -- id_estacao, + -- acumulado_chuva_10_min AS acumulado_chuva_15_min, + -- CURRENT_DATE('America/Sao_Paulo') as data, + -- data_update + -- FROM ( + -- SELECT + -- id_estacao, + -- acumulado_chuva_10_min, + -- data_particao, + -- DATETIME(data_medicao) AS data_update, + -- ROW_NUMBER() OVER ( + -- PARTITION BY id_estacao ORDER BY DATETIME(data_medicao) DESC + -- ) AS row_num + -- FROM `rj-cor.clima_pluviometro.taxa_precipitacao_cemaden` + -- WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 1 DAY) + -- AND data_medicao >= TIMESTAMP_SUB(CURRENT_DATETIME('America/Sao_Paulo'), INTERVAL 30 MINUTE) + -- )AS a + -- WHERE a.row_num = 1 + -- ), last_measurements AS (-- concatena medições do alertario, cemaden e websirene (SELECT @@ -397,20 +397,20 @@

Classes

"alertario" AS sistema, acumulado_chuva_15_min, FROM alertario) - UNION ALL - (SELECT - id_estacao, - data_update, - "websirene" AS sistema, - acumulado_chuva_15_min, - FROM websirene) - UNION ALL - (SELECT - id_estacao, - data_update, - "cemaden" AS sistema, - acumulado_chuva_15_min, - FROM cemaden) + -- UNION ALL + -- (SELECT + -- id_estacao, + -- data_update, + -- "websirene" AS sistema, + -- acumulado_chuva_15_min, + -- FROM websirene) + -- UNION ALL + -- (SELECT + -- id_estacao, + -- data_update, + -- "cemaden" AS sistema, + -- acumulado_chuva_15_min, + -- FROM cemaden) ), h3_chuvas AS ( -- calcula qnt de chuva para cada h3 @@ -436,22 +436,22 @@

Classes

ST_GEOGPOINT(CAST(longitude AS FLOAT64), CAST(latitude AS FLOAT64)) AS geom FROM `rj-cor.clima_pluviometro.estacoes_alertario`) - UNION ALL - (SELECT - id_estacao AS id, - estacao, - "websirene" AS sistema, - ST_GEOGPOINT(CAST(longitude AS FLOAT64), - CAST(latitude AS FLOAT64)) AS geom - FROM `rj-cor.clima_pluviometro.estacoes_websirene`) - UNION ALL - (SELECT - id_estacao AS id, - estacao, - "cemaden" AS sistema, - ST_GEOGPOINT(CAST(longitude AS FLOAT64), - CAST(latitude AS FLOAT64)) AS geom - FROM `rj-cor.clima_pluviometro.estacoes_cemaden`) + -- UNION ALL + -- (SELECT + -- id_estacao AS id, + -- estacao, + -- "websirene" AS sistema, + -- ST_GEOGPOINT(CAST(longitude AS FLOAT64), + -- CAST(latitude AS FLOAT64)) AS geom + -- FROM `rj-cor.clima_pluviometro.estacoes_websirene`) + -- UNION ALL + -- (SELECT + -- id_estacao AS id, + -- estacao, + -- "cemaden" AS sistema, + -- ST_GEOGPOINT(CAST(longitude AS FLOAT64), + -- CAST(latitude AS FLOAT64)) AS geom + -- FROM `rj-cor.clima_pluviometro.estacoes_cemaden`) ), estacoes_mais_proximas AS ( @@ -527,10 +527,10 @@

Classes

ELSE 'sem chuva' END AS status, CASE - WHEN chuva_15min> 0 AND chuva_15min<= 1.25 THEN '#DAECFB'--'#00CCFF' - WHEN chuva_15min> 1.25 AND chuva_15min<= 6.25 THEN '#A9CBE8'--'#BFA230' - WHEN chuva_15min> 6.25 AND chuva_15min<= 12.5 THEN '#77A9D5'--'#E0701F' - WHEN chuva_15min> 12.5 THEN '#125999'--'#FF0000' + WHEN chuva_15min> 0 AND chuva_15min<= 1.25 THEN '#DAECFB' + WHEN chuva_15min> 1.25 AND chuva_15min<= 6.25 THEN '#A9CBE8' + WHEN chuva_15min> 6.25 AND chuva_15min<= 12.5 THEN '#77A9D5' + WHEN chuva_15min> 12.5 THEN '#125999' ELSE '#ffffff' END AS color FROM final_table @@ -548,26 +548,26 @@

Classes

WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 2 DAY) AND CAST(CONCAT(data_particao, " ", horario) AS DATETIME) <= CURRENT_DATETIME('America/Sao_Paulo') ) - UNION ALL - ( - SELECT - MAX( - DATETIME( - CONCAT(data_particao," ", horario) - ) - ) AS last_update - FROM `rj-cor.clima_pluviometro.taxa_precipitacao_websirene` - WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 2 DAY) - AND CAST(CONCAT(data_particao, " ", horario) AS DATETIME) <= CURRENT_DATETIME('America/Sao_Paulo') - ) - UNION ALL - ( - SELECT - MAX(DATETIME(data_medicao)) AS last_update - FROM `rj-cor.clima_pluviometro.taxa_precipitacao_cemaden` - WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 2 DAY) - AND data_medicao <= CURRENT_DATETIME('America/Sao_Paulo') - ) + -- UNION ALL + -- ( + -- SELECT + -- MAX( + -- DATETIME( + -- CONCAT(data_particao," ", horario) + -- ) + -- ) AS last_update + -- FROM `rj-cor.clima_pluviometro.taxa_precipitacao_websirene` + -- WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 2 DAY) + -- AND CAST(CONCAT(data_particao, " ", horario) AS DATETIME) <= CURRENT_DATETIME('America/Sao_Paulo') + -- ) + -- UNION ALL + -- ( + -- SELECT + -- MAX(DATETIME(data_medicao)) AS last_update + -- FROM `rj-cor.clima_pluviometro.taxa_precipitacao_cemaden` + -- WHERE data_particao> DATE_SUB(CURRENT_DATE('America/Sao_Paulo'), INTERVAL 2 DAY) + -- AND data_medicao <= CURRENT_DATETIME('America/Sao_Paulo') + -- ) ) SELECT MAX(last_update) AS last_update diff --git a/rj_escritorio/rain_dashboard/flows.html b/rj_escritorio/rain_dashboard/flows.html index 6d48159d4..ad216dd18 100644 --- a/rj_escritorio/rain_dashboard/flows.html +++ b/rj_escritorio/rain_dashboard/flows.html @@ -53,7 +53,7 @@

Module pipelines.rj_escritorio.rain_dashboard.flows