#' artlookR survey_years metadata
#'
#' @param comm_name The community name as recognized by artlookR
#' @return A list with:
#' * \code{current_survey_year_id} the artlookR id for the community's current survey year.
#' * \code{current_survey_year} the display name of the community's current survey year.
#' * \code{id} the artlookR id for each survey created for this community.
#' * \code{name} the display name for each survey created for this community.
#' * \code{state} the deployment status (e.g., published) for each survey created for this community.
#' * \code{school_year_id} the artlookR id for the school year associated with each survey created for this community.
#' * \code{school_year} the display name for the school year associated with each survey created for this community.
#' * \code{category} the school \code{category} that received each survey created for this community.
#' * \code{due_date} the due date associated with each survey created for this community.
#' @details You will need to run the \code{connection.R} script and create a connection object named \code{myconn} for this script to run.
#' @examples meta_survey_years("chicago")
#' @export
meta_survey_years <- function(comm_name){
fact_years <- meta_years(comm_name)
temp <- tbl(myconn, in_schema(comm_name, "surveys")) %>%
select(id, name, state, school_year_id, category, due_date) %>%
collect %>%
mutate(school_year = factor(school_year_id, levels = fact_years$level, labels = fact_years$label, ordered = TRUE))
output <- list(current_survey_yr_id = temp %>% filter(state == "published") %>% summarise(max(school_year_id)) %>% pull,
current_survey_year = temp %>% filter(state == "published") %>% summarise(max(school_year)) %>% pull,
id = temp$id,
name = temp$name,
state = temp$state,
school_year_id = temp$school_year_id,
school_year = temp$school_year,
category = temp$category,
due_date = temp$due_date)
output
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.