Commit 6df8a37c9a52ebe446af276cc83fae7956995d02
1 parent
8d5016bc
Exists in
master
and in
111 other branches
getGranules only returns non-null columns.
Showing
1 changed file
with
30 additions
and
5 deletions
Show diff stats
php/classes/EpnTapMgr.php
... | ... | @@ -49,12 +49,37 @@ class EpnTapMgr { |
49 | 49 | |
50 | 50 | $query = "SELECT TOP {$limit} * FROM {$table_name} " . $this->createFilter($filter[0], $filter[1], $filter[2], $filter[3]) . " OFFSET {$offset}"; |
51 | 51 | $result = $this->request($access_url, $query); |
52 | - if(! array_key_exists("error", $result)) { | |
53 | 52 | |
54 | - for ($i = 0 ; $i < count($result) ; $i++) { | |
55 | - $result[$i]['num'] = $i + $offset + 1; | |
56 | - $result[$i]['time_min'] = $this->JDTodate($result[$i]['time_min']); | |
57 | - $result[$i]['time_max'] = $this->JDTodate($result[$i]['time_max']); | |
53 | + $result_path = EpnTapDataPath . "test_result.json"; | |
54 | + $servicesJsonFile = fopen($result_path, "w"); | |
55 | + | |
56 | + if(array_key_exists("error", $result)) { | |
57 | + return $result; | |
58 | + } | |
59 | + | |
60 | + $columns_with_empty_results = Array(); | |
61 | + for ($i = 0 ; $i < count($result) ; $i++) { | |
62 | + $result[$i]['num'] = $i + $offset + 1; | |
63 | + $result[$i]['time_min'] = $this->JDTodate($result[$i]['time_min']); | |
64 | + $result[$i]['time_max'] = $this->JDTodate($result[$i]['time_max']); | |
65 | + | |
66 | + foreach($result[$i] as $key => $value) { | |
67 | + if($value === '' || $value === 'NAN') { | |
68 | + if(!array_key_exists($key, $columns_with_empty_results)) { | |
69 | + array_push($columns_with_empty_results, $key); | |
70 | + } | |
71 | + } elseif(array_key_exists($key, $columns_with_empty_results)) { | |
72 | + unset($columns_with_empty_results[$key]); | |
73 | + } | |
74 | + } | |
75 | + } | |
76 | + | |
77 | + // TODO: maybe is it better to have a array of booleans, like {"target_name": true, "c1min", false}, to apply an array_map() ? | |
78 | + for($i = 0 ; $i < count($result) ; $i++) { | |
79 | + foreach($result[$i] as $key => $value) { | |
80 | + if(in_array($key, $columns_with_empty_results)) { | |
81 | + unset($result[$i][$key]); | |
82 | + } | |
58 | 83 | } |
59 | 84 | } |
60 | 85 | |
... | ... |