Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial data clean-up for ancillary files #90

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/deploy-shiny.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ jobs:
RENV_PATHS_ROOT: ~/.local/share/renv

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
r-version: 4.2.1
use-public-rspm: true

- name: Set env vars (dev)
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@
.RData
.Ruserdata
rsconnect
data/EES_aut_data.csv
data/EES_daily_data.csv
data/EES_spr_data.csv
data/EES_sum_data.csv
data/EES_weekly_data.csv
data/EES_ytd_data.csv
data/sql_export*
data/export*
data/enrolment*
9 changes: 6 additions & 3 deletions R/prerun_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -1189,9 +1189,7 @@ process_attendance_data_spring <- function(attendance_data_raw, spring_start, sp
# }

#### SECTION 6 - Creating EES tables for daily, weekly and year to date ####
create_ees_tables <- function(attendance_data) {
# Set up data for download
# EES daily data/download data
create_EES_daily_data <- function(attendance_data) {
EES_daily_data <- attendance_data %>%
dplyr::filter(breakdown == "Daily") %>%
dplyr::select(
Expand Down Expand Up @@ -1314,7 +1312,12 @@ create_ees_tables <- function(attendance_data) {
auth_other_perc
), ~
replace(., geographic_level == "Local authority" & num_schools == 1, "c"))
}

create_ees_tables <- function(attendance_data) {
# Set up data for download
# EES daily data/download data
EES_daily_data <- create_EES_daily_data(attendance_data)
# EES_daily_data[is.na(EES_daily_data)]<-"c"

# EES weekly data
Expand Down
2 changes: 1 addition & 1 deletion global.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ attendance_data <- read.csv("data/attendance_data_dashboard.csv")

message(paste("Finished processing steps, ", Sys.time()))

EES_daily_data <- read_ees_daily()
EES_daily_data <- create_EES_daily_data(attendance_data)

#### SECTION 3 - Lookups ####
# Add geog lookup
Expand Down
96 changes: 7 additions & 89 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,95 +25,13 @@ server <- function(input, output, session) {
hide(id = "loading-content", anim = TRUE, animType = "fade")
show("app-content")

# Cookie consent scripts
observeEvent(input$cookies, {
if (!is.null(input$cookies)) {
if (!("dfe_analytics" %in% names(input$cookies))) {
shinyjs::show(id = "cookieMain")
} else {
shinyjs::hide(id = "cookieMain")
msg <- list(
name = "dfe_analytics",
value = input$cookies$dfe_analytics
)
session$sendCustomMessage("analytics-consent", msg)
if ("cookies" %in% names(input)) {
if ("dfe_analytics" %in% names(input$cookies)) {
if (input$cookies$dfe_analytics == "denied") {
ga_msg <- list(name = paste0("_ga_", google_analytics_key))
session$sendCustomMessage("cookie-remove", ga_msg)
}
}
}
}
} else {
shinyjs::hide(id = "cookieMain")
}
})

# Need these set of observeEvent to create a path through the cookie banner
observeEvent(input$cookieAccept, {
msg <- list(
name = "dfe_analytics",
value = "granted"
)
session$sendCustomMessage("cookie-set", msg)
session$sendCustomMessage("analytics-consent", msg)
shinyjs::show(id = "cookieAcceptDiv")
shinyjs::hide(id = "cookieMain")
})

observeEvent(input$cookieReject, {
msg <- list(
name = "dfe_analytics",
value = "denied"
)
session$sendCustomMessage("cookie-set", msg)
session$sendCustomMessage("analytics-consent", msg)
shinyjs::show(id = "cookieRejectDiv")
shinyjs::hide(id = "cookieMain")
})

observeEvent(input$hideAccept, {
shinyjs::toggle(id = "cookieDiv")
})

observeEvent(input$hideReject, {
shinyjs::toggle(id = "cookieDiv")
})

observeEvent(input$remove, {
shinyjs::toggle(id = "cookieMain")
msg <- list(name = "dfe_analytics", value = "denied")
session$sendCustomMessage("cookie-remove", msg)
session$sendCustomMessage("analytics-consent", msg)
})

cookies_data <- reactive({
input$cookies
})

output$cookie_status <- renderText({
cookie_text_stem <- "To better understand the reach of our dashboard tools, this site uses cookies to identify numbers of unique users as part of Google Analytics. You have chosen to"
cookie_text_tail <- "the use of cookies on this website."
if ("cookies" %in% names(input)) {
if ("dfe_analytics" %in% names(input$cookies)) {
if (input$cookies$dfe_analytics == "granted") {
paste(cookie_text_stem, "accept", cookie_text_tail)
} else {
paste(cookie_text_stem, "reject", cookie_text_tail)
}
}
} else {
"Cookies consent has not been confirmed."
}
})

observeEvent(input$cookieLink, {
# Need to link here to where further info is located. You can
# updateTabsetPanel to have a cookie page for instance
updateTabsetPanel(session, "navlistPanel", selected = "Support and feedback")
})
output$cookie_status <- dfeshiny::cookie_banner_server(
"cookies",
input_cookies = reactive(input$cookies),
input_clear = reactive(input$cookie_consent_clear),
parent_session = session,
google_analytics_key = google_analytics_key
)

# Navigation with links
observeEvent(input$link_to_headlines_tab, {
Expand Down
Binary file modified tests/testthat/_snaps/UI_tests/001_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/UI_tests/002_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/UI_tests/003_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/UI_tests/004_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/UI_tests/005_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/UI_tests/006_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/UI_tests/007_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/UI_tests/008_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/UI_tests/009_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/UI_tests/010_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/UI_tests/011_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/UI_tests/012_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/UI_tests/013_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/UI_tests/014_.new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 2 additions & 12 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,8 @@ ui <- function(input, output, session) {

customDisconnectMessage(),
useShinydashboard(),
# Setting up cookie consent based on a cookie recording the consent:
# https://book.javascript-for-r.com/shiny-cookies.html
tags$head(
tags$script(
src = paste0(
"https://cdn.jsdelivr.net/npm/js-cookie@rc/",
"dist/js.cookie.min.js"
)
),
tags$script(src = "cookie-consent.js")
),
dfe_cookie_script(),
cookie_banner_ui("cookies", name = "DfE pupil attendance and absence in schools in England"),
tags$head(includeHTML(("google-analytics.html"))),
tags$head(
tags$link(
Expand All @@ -63,7 +54,6 @@ ui <- function(input, output, session) {
href = "dfe_shiny_gov_style.css"
)
),
shinyGovstyle::cookieBanner("DfE pupil attendance and absence in schools in England"),
shinyGovstyle::header(
main_text = "",
secondary_text = "DfE pupil attendance and absence in schools in England: data dashboard",
Expand Down
Loading