Skip to content

Handle missing pinsΒ #1

@russHyde

Description

@russHyde

@keithnewman

This line fails when searching for a pin for 2026:

pins::pin_read(board = board_ref, name = sprintf(pin_name_template, year))

The data-preparation script isn't populating the data for 2026 yet.
The app is currently failing as a result.
Could we do something like

load_all_data <- function(board_ref, starting_year_end, pin_name_template) {        
  pin_reader = function(year) {                                                                                                                                          
        pins::pin_read(board = board_ref, name = sprintf(pin_name_template, year))                                                                              
      }                                                                           
  requireNamespace("nanoparquet", quietly = TRUE)                                                                                                               
  seq(from = starting_year_end, to = get_year_end(Sys.Date())) |>                                                                                               
    rlang::set_names() |>                                                                                                                                       
    purrr::map(
        # data for the current year is read from a pin if it exists, otherwise from an empty data-frame
        purrr::safely(pin_reader, NULL)                                                                                              
    ) |>                                                                                                                                                        
    purrr::list_rbind(names_to = "year_end")                                                                                                                    
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions