From 33972182ebf073f08e9893c46bd54ecb575dbb7c Mon Sep 17 00:00:00 2001 From: PromInc Date: Fri, 28 Aug 2015 13:51:53 -0500 Subject: [PATCH] Bug fix import of multiple search types was not working, fixed now --- inc/code/dataCapture.php | 42 ++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/inc/code/dataCapture.php b/inc/code/dataCapture.php index 2f7c319..c5fbd04 100644 --- a/inc/code/dataCapture.php +++ b/inc/code/dataCapture.php @@ -67,6 +67,7 @@ public function checkNeededDataGoogleSearchAnalytics($website) { public function downloadGoogleSearchAnalytics($website,$date) { + $importCount = 0; /* Website requires a trailing slash */ // if( substr( $website, -1 ) != "/" ) { $website .= "/"; } @@ -88,32 +89,27 @@ public function downloadGoogleSearchAnalytics($website,$date) { /* Build Search Analytics Request */ $searchAnalyticsRequest->setDimensions(['query','device']); -// $searchAnalyticsRequest->setDimensions( array('query','device') ); $searchAnalyticsRequest->setRowLimit( 5000 ); /* Valid options: 1-5000 */ - /* Loop through each of the dates requested */ -/* foreach( $dateList as $dateListIndex => $date ) { */ - - /* Set date for Search Analytics Request */ - $searchAnalyticsRequest->setStartDate( $date ); - $searchAnalyticsRequest->setEndDate( $date ); - /* Loop through each of the search types */ - foreach( $searchTypes as $searchTypesIndex => $searchType ) { - - /* Set search type in Search Analytics Request */ - $searchAnalyticsRequest->setSearchType( $searchType ); - - /* Send Search Analytics Request */ - $searchAnalyticsResponse = $searchanalytics->query( $website, $searchAnalyticsRequest); - - /* Import Search Analytics to Database */ - if( is_object( $searchAnalyticsResponse ) ) { - $wmtimport = new WMTimport(); - - return $wmtimport->importGoogleSearchAnalytics( $website, $date, $searchType, $searchAnalyticsResponse ); - } + /* Set date for Search Analytics Request */ + $searchAnalyticsRequest->setStartDate( $date ); + $searchAnalyticsRequest->setEndDate( $date ); + /* Loop through each of the search types */ + foreach( $searchTypes as $searchType ) { + /* Set search type in Search Analytics Request */ + $searchAnalyticsRequest->setSearchType( $searchType ); + + /* Send Search Analytics Request */ + $searchAnalyticsResponse = $searchanalytics->query( $website, $searchAnalyticsRequest); + + /* Import Search Analytics to Database */ + if( is_object( $searchAnalyticsResponse ) ) { + $wmtimport = new WMTimport(); + $importCount += $wmtimport->importGoogleSearchAnalytics( $website, $date, $searchType, $searchAnalyticsResponse ); } -/* } */ + } + + return $importCount; }