Export portal datasets as versioned JSON files to public cloud storage
Source:R/export.R
export_files.RdOrchestrates the portal data export workflow:
Downloads multiple precomputed objects from public cloud storage via
get_file().Standardizes column names via
rename_ontology().Formats time-binned tables via
format_aggregated_data().Computes summary tables (
estimated_tons,estimated_revenue) and a curatedsummary_datalist for portal use.Writes each object to pretty-printed JSON with versioned filenames and uploads them to public cloud storage.
Details
The exported JSON objects are exactly the seven the live portal consumes:
aggregated, taxa_aggregated, municipal_aggregated, municipal_taxa,
nutrients_aggregated, data_last_updated and summary_data. The contract
is discovery-based — peskas.timor.portal.v2/scripts/fetchData.js lists
the bucket for the portal- prefix and keeps the newest version of each — so
renaming or dropping one of these seven does not fail a build, it silently
removes a page from the live site.
The function expects summary_data (downloaded) to contain fields such as
n_surveys, catch_norm, catch_price_norm, nutrients_per_catch,
nutrients_norm, conservation, cpue_df, and timor_shape.
Assumes a configured public Google cloud storage provider in
conf$public_storage$google and relies on helper functions such as
add_version(), coasts::upload_cloud_file(), and JSON serialization via toJSON().