Skip to content

Instantly share code, notes, and snippets.

@maggiben
Created October 8, 2015 17:19
Show Gist options
  • Save maggiben/1b8e8f902dedb28c9824 to your computer and use it in GitHub Desktop.
Save maggiben/1b8e8f902dedb28c9824 to your computer and use it in GitHub Desktop.
$unit = $this->get_mapped_unit( $entity['data']['units'] );
$values = array_map( function($v) use ($unit) {
if (strcmp($v, ".") !== 0) {
return $v * $unit['multiplier'];
} else {
return null;
}
}, wp_list_pluck( $data, 'value' ) );
$data = array(
'interval' => strtotime( $data[1]->date ) - strtotime( $data[0]->date ),
'data' => json_encode($values, JSON_NUMERIC_CHECK), //$values,
'units' => $unit['unit'],
'start' => strtotime( $data[0]->date ),
'end' => strtotime( $to ),
'name' => $entity['name'],
'metric' => $metric['name'],
'source' => $entity['data']['source']['name'],
'observation_start' => $entity['data']['observation_start']
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment