Skip to contents

Downloads the versioned assets snapshot written by ingest_assets() and returns the mapping tables for the requested form(s), ready to join against survey data.

Usage

get_assets(
  form_ids,
  prefix,
  provider,
  options,
  tables = c("taxa", "gear", "vessels", "sites", "geo"),
  drop_cols = c("country", "latitude", "longitude"),
  version = "latest"
)

Arguments

form_ids

Character vector of Airtable form record IDs, e.g. from one or more get_airtable_form_id() calls.

prefix

Character. Storage prefix of the assets snapshot.

provider

Character. Storage provider key.

options

List. Storage options for the bucket holding the snapshot.

tables

Character vector of asset tables to return.

drop_cols

Columns removed from every table before de-duplication.

version

Snapshot version to read; defaults to the most recent.

Value

A named list of tibbles, one per entry in tables.

Details

This is the read-side counterpart to ingest_assets(). The snapshot stores every country's assets in one object, with form_id as a comma-separated list of the forms each record belongs to — a shape created here, by airtable_to_df(). Decoding it correctly (whole-element match, not substring) is knowledge that belongs next to the code that encodes it, not copied into each country pipeline.

drop_cols exists because the snapshot carries columns that are useful for partitioning but harmful to join on. country rides on taxa, gear, vessels and geo alike, so leaving it in place makes it collide across the successive joins downstream; latitude/longitude are free-text fields on sites. Dropping them can make previously distinct rows identical, so distinct() is applied after the drop, not before.

A table that filters down to zero rows is warned about rather than returned silently: it almost always means the form id is valid but wrong, which would otherwise surface only as an all-NA column far downstream.

Examples

if (FALSE) { # \dontrun{
assets <- get_assets(
  form_ids = get_airtable_form_id(conf$ingestion$wcs$asset_id, conf),
  prefix   = conf$metadata$airtable$assets,
  provider = conf$storage$google$key,
  options  = conf$storage$google$options_coasts
)
assets$taxa
} # }