Browse Source

Dates actualisées au rafraîchissement

static
Maxime Wack 6 years ago
parent
commit
ca0fbbd5eb
1 changed files with 36 additions and 29 deletions
  1. +36
    -29
      app.R

+ 36
- 29
app.R View File

@@ -28,33 +28,6 @@ villespe %>%
arrange(Discipline) %>%
pull(Discipline) -> spes

# Last update ----
Sys.setlocale("LC_TIME", "fr_FR.UTF-8")
db %>%
tbl("trajectoires") %>%
select(timestamp) %>%
distinct %>%
collect(n = Inf) %>%
pull(timestamp) %>%
max %>%
as.POSIXct %>%
format(format = "%A %d %B %Y %H:%M") %>%
str_to_title ->
last_update

# Epoch ----
db %>%
tbl("trajectoires") %>%
select(timestamp) %>%
distinct %>%
collect(n = Inf) %>%
pull(timestamp) %>%
min %>%
as.POSIXct %>%
format(format = "%A %d %B %Y %H:%M") %>%
str_to_title ->
epoch

# Max rank ----
db %>%
tbl("trajectoires") %>%
@@ -70,8 +43,7 @@ db %>% dbDisconnect
# UI ----
ui <- shinyUI(fluidPage(
titlePanel("Celine Stalker"),
p(str_c("Données à partir du ", epoch)),
p(str_c("Dernières données du ", last_update)),
uiOutput("dates"),
sidebarLayout(
sidebarPanel(radioButtons("Select", "Chercher par", choices = c("étudiant", "ville + spé"), selected = "étudiant"),
conditionalPanel("input.Select == 'ville + spé'",
@@ -91,6 +63,41 @@ ui <- shinyUI(fluidPage(
# Server ----
server <- shinyServer(function(input, output)
{
output$dates <- renderUI({

dbConnect(SQLite(), "ecn.db", on.exit(dbDisconnect(db), add = T)) -> db

# Last update ----
Sys.setlocale("LC_TIME", "fr_FR.UTF-8")
db %>%
tbl("trajectoires") %>%
select(timestamp) %>%
distinct %>%
collect(n = Inf) %>%
pull(timestamp) %>%
max %>%
as.POSIXct %>%
format(format = "%A %d %B %Y %H:%M") %>%
str_to_title ->
last_update

# Epoch ----
db %>%
tbl("trajectoires") %>%
select(timestamp) %>%
distinct %>%
collect(n = Inf) %>%
pull(timestamp) %>%
min %>%
as.POSIXct %>%
format(format = "%A %d %B %Y %H:%M") %>%
str_to_title ->
epoch

list(p(str_c("Données à partir du ", epoch)),
p(str_c("Dernières données du ", last_update)))
})

outTable <- reactive({
req(input$Select, input$Ville, input$Spe, input$Etudiant)



Loading…
Cancel
Save