Skip to content

Commit 95b91ac

Browse files
authored
Update eventos-md.R
1 parent dcce47f commit 95b91ac

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

R/eventos-md.R

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,29 @@ tb <- tb %>%
2222
select(evento, fecha_evento_inicio, modalidad, ciudad, pais, colaboran, equipo, participacion) %>%
2323
mutate(anio = year(fecha_evento_inicio))
2424

25+
# Eventos realizados en el año hasta la fecha
26+
27+
ahora <- Sys.time() - hours(3)
28+
hoy <- as_date(ahora)
29+
anio_actual <- year(hoy)
30+
31+
eventos_a_la_fecha <- tb %>%
32+
# Solo eventos del año actual cuya fecha de inicio ya pasó o es hoy
33+
filter(anio == anio_actual,
34+
as_date(fecha_evento_inicio) <= hoy) %>%
35+
distinct(evento) %>%
36+
summarise(
37+
ultima_actualizacion = ahora,
38+
cantidad_eventos = n()
39+
)
40+
41+
# Escribir/actualizar hoja "a-la-fecha"
42+
write_sheet(
43+
data = eventos_a_la_fecha,
44+
ss = hoja_calculo,
45+
sheet = "a_la_fecha"
46+
)
47+
2548
# Cantidad de eventos por anio y modalidad
2649
modalidad_anio <- tb %>%
2750
distinct(evento, .keep_all = TRUE) %>%
@@ -106,7 +129,7 @@ write_sheet(data = resumen_anio,
106129

107130
# Registrar horario de última actualización
108131
# Levantar hora actual
109-
ultima_actualizacion <- data.frame(timestamp = Sys.time()-hours(3))
132+
ultima_actualizacion <- data.frame(timestamp = ahora)
110133

111134
# Escribir la timestamp a una nueva hoja llamada "ultima_actualizacion"
112135
write_sheet(ultima_actualizacion,

0 commit comments

Comments
 (0)