Decides which of the trips a PDS token returns are this country's. It does no network or cloud work, so you can run it on a downloaded trip table to see what a config change would do before making it.
Usage
select_country_trips(
trips,
devices,
customers = NULL,
exclude_customers = NULL,
select_by = c("device", "community")
)Arguments
- trips
Trip table from
get_trips(), fetched withdeviceInfo = TRUE. Without that there is noIMEIorCommunitycolumn.- devices
The
devicestable from the assets snapshot. Needsimei,customer_name, andcommunityfor the community rule.- customers
Allowlist of
customer_namevalues.- exclude_customers
Denylist of
customer_namevalues.character(0)means "exclude nothing", which is different from leaving it unset.- select_by
"device"(who owns it now) or"community"(where the trip happened). Applies tocustomersonly.
Value
trips, filtered. Keeping nothing is an error, because an empty
parquet becomes the latest version and empties the portal.
The three rules
select_by = "device"withcustomers— keep trips whose device is under those customers now. The default, and lossy: a tracker sold on or shipped abroad takes its whole trip history with it.exclude_customers— keep everything except devices under those customers. Redeployed hardware keeps its history, but nothing here can reject another country's trips, so use it only on a country-scoped token.select_by = "community"withcustomers— keep trips that happened at one of those customers' communities. Recommended: a trip's community does not change when the hardware is reassigned.
Measure before switching a country to "community"
Communities come from current device records, so a landing site with no device left on it drops out and takes its trips with it. Run both rules over one trip table and compare the counts before changing a config.
