Commit 889ea43ea225c3db1607e85106e9d454e573d542
1 parent
dedfdaf5
ga output
Showing
1 changed file
with
4 additions
and
3 deletions
Show diff stats
app/library/App/Controllers/GaController.php
@@ -40,8 +40,7 @@ class GaController extends CrudResourceController { | @@ -40,8 +40,7 @@ class GaController extends CrudResourceController { | ||
40 | $projects = Project::find(['user_id' => $user_id]); | 40 | $projects = Project::find(['user_id' => $user_id]); |
41 | foreach ($projects as $project) { | 41 | foreach ($projects as $project) { |
42 | $view_id = (string)$project->ga_view_id; | 42 | $view_id = (string)$project->ga_view_id; |
43 | - $result[] = ['name' => $project->name]; | ||
44 | - $result[] = $this->sendGaRequest($view_id, $get_metrics, $get_dimensions, $get_start_date, $get_end_date); | 43 | + $result[] = $this->sendGaRequest($project->name, $view_id, $get_metrics, $get_dimensions, $get_start_date, $get_end_date); |
45 | } | 44 | } |
46 | } | 45 | } |
47 | else { | 46 | else { |
@@ -83,7 +82,7 @@ class GaController extends CrudResourceController { | @@ -83,7 +82,7 @@ class GaController extends CrudResourceController { | ||
83 | return $res; | 82 | return $res; |
84 | } | 83 | } |
85 | 84 | ||
86 | - public function sendGaRequest($view, $get_metrics, $get_dimensions, $start, $end) { | 85 | + public function sendGaRequest($project_name, $view, $get_metrics, $get_dimensions, $start, $end) { |
87 | 86 | ||
88 | putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/phalcon/'.self::SECRET_JSON); | 87 | putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/phalcon/'.self::SECRET_JSON); |
89 | $client = new Google_Client(); | 88 | $client = new Google_Client(); |
@@ -142,6 +141,8 @@ class GaController extends CrudResourceController { | @@ -142,6 +141,8 @@ class GaController extends CrudResourceController { | ||
142 | $metric_val = $item['metrics'][0]['values']; | 141 | $metric_val = $item['metrics'][0]['values']; |
143 | $dimension_val = $item['dimensions'][0]; | 142 | $dimension_val = $item['dimensions'][0]; |
144 | 143 | ||
144 | + $result['name'] = $project_name; | ||
145 | + | ||
145 | if (count($metric_val) > 1) { | 146 | if (count($metric_val) > 1) { |
146 | for ($i = 0; $i < count($metric_val); $i++) { | 147 | for ($i = 0; $i < count($metric_val); $i++) { |
147 | $result[$dimension_val][] = $metric_val[$i]; | 148 | $result[$dimension_val][] = $metric_val[$i]; |