britishredcrosssociety / local-lockdown

R Shiny dashboard for visualising information related to Covid-19 Test & Trace and local lockdowns
Other
1 stars 1 forks source link

Performance #20

Open MikeJohnPage opened 4 years ago

MikeJohnPage commented 4 years ago
MikeJohnPage commented 4 years ago
MikeJohnPage commented 4 years ago

In this file which generates carpark locations, the code which iterates through the list of .xml files from the gov website can be replaced with the following:

GET("https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/388117/IF064_052_201412160800.zip",
    write_disk(tf <- tempfile(fileext = ".zip")))

unzip(tf, exdir = tempdir())

unlink(tf); rm(tf)

cp_files = list.files(tempdir(), pattern = "Car*", full.names = TRUE)

It writes the .xml files to a temporary directory and then reads them from there. This means the carpark .xml files can be removed from data/, reducing the size of the app.

MikeJohnPage commented 4 years ago

Likewise with the postcode data:

GET("https://www.arcgis.com/sharing/rest/content/items/82889274464b48ae8bf3e9458588a64b/data",
    write_disk(tf <- tempfile(fileext = ".zip")))

unzip(tf, exdir = tempdir())
unlink(tf); rm(tf)

# load postcode directory and keep only relevant fields - we just need MSOA
postcodes_raw = read_csv(paste0(tempdir(), "/Data/ONSPD_FEB_2020_UK.csv"))
MikeJohnPage commented 3 years ago