get data and save it for the overview

@param AnalyticsOverview $overview The overview
545812
public function getData(&$overview)
    {
        $this->output->writeln("\t" . 'Fetching chart data..');

        // execute the query
        $metrics = 'ga:sessions, ga:users, ga:newUsers, ga:pageviews';
        $rows = $this->executeQuery($overview, $metrics);

        $chartData = array();
        $chartDataMaxValue = 0;
        $timespan = $overview->getTimespan() - $overview->getStartOffset();
        foreach ($rows as $row) {
            // metrics
            $sessions = $row[count($row) - 4];
            $users = $row[count($row) - 3];
            $newusers = $row[count($row) - 2];
            $pageviews = $row[count($row) - 1];

            $maxvalue = max($sessions, $users, $newusers, $pageviews);
            // set max chartdata value
            if ($chartDataMaxValue < $maxvalue) {
                $chartDataMaxValue = $maxvalue;
            }

            // timestamp
            if ($timespan <= 1) {
                $timestamp = mktime($row[1], 0, 0, substr($row[0], 4, 2), substr($row[0], 6, 2), substr($row[0], 0, 4));
                $timestamp = date('Y-m-d H:00', $timestamp);
            } elseif ($timespan <= 7) {
                $timestamp = mktime($row[1], 0, 0, substr($row[0], 4, 2), substr($row[0], 6, 2), substr($row[0], 0, 4));
                $timestamp = date('Y-m-d H:00', $timestamp);
            } elseif ($timespan <= 31) {
                $timestamp = mktime(0, 0, 0, substr($row[2], 4, 2), substr($row[2], 6, 2), substr($row[2], 0, 4));
                $timestamp = date('Y-m-d H:00', $timestamp);
            } else {
                $timestamp = strtotime(substr($row[0], 0, 4) . 'W' . substr($row[0], 4, 2));
                $timestamp = date('Y-m-d H:00', $timestamp);
            }

            // add to chart array
            $chartEntry = array(
                'timestamp' => $timestamp,
                'sessions' => $sessions,
                'users' => $users,
                'newusers' => $newusers,
                'pageviews' => $pageviews,
            );
            $chartData[] = $chartEntry;
        }

        // adding data to the overview
        $overview->setChartDataMaxValue($chartDataMaxValue);
        $overview->setChartData(json_encode($chartData, JSON_NUMERIC_CHECK));
    }
979951
protected function executeQuery(AnalyticsOverview $overview, $metrics)
    {
        $timestamps = $this->getTimestamps($overview);
        $extra = $this->getExtra($overview);

        // execute query
        $results = $this->query->getResultsByDate(
            $timestamps['begin'],
            $timestamps['end'],
            $metrics,
            $extra
        );

        return $results->getRows();
    }
615149
public function get_static_data() {
        // Delegates all processing to the analysis.
        $result = new \core_analytics\local\analysis\result_array($this->get_modelid(), false, $this->get_options());
        $analysis = new \core_analytics\analysis($this, false, $result);
        $analysis->run();
        return $result->get();
    }
411510
public function overviewAction()
    {
        /** @var StorageInterface $storage */
        $storage = $this->get('lexik_translation.translation_storage');

        $stats = $this->get('lexik_translation.overview.stats_aggregator')->getStats();

        return $this->render('@LexikTranslation/Translation/overview.html.twig', array(
            'layout'         => $this->container->getParameter('lexik_translation.base_layout'),
            'locales'        => $this->getManagedLocales(),
            'domains'        => $storage->getTransUnitDomains(),
            'latestTrans'    => $storage->getLatestUpdatedAt(),
            'stats'          => $stats,
        ));
    }
179570
public function overviewAction()
    {
        if ($this->overviewSnippets) {
            $params = $this->_processParameters($this->overviewParameters);

            $this->addSnippets($this->overviewSnippets, $params);
        }
    }
514470
private function getOverviewsOfConfig($configId)
    {
        // get specified config
        $configRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig');
        $config = $configRepository->find($configId);

        if (!$config) {
            throw new \Exception('Unkown config ID');
        }

        // get the overviews
        return $config->getOverviews();
    }
1024420
public function overview()
    {
        /** @var PingService $pinger */
        $pinger = $this->app['extend.ping'];
        // Ping the extensions server to confirm connection
        $this->app['extend.online'] = $pinger->ping(true);

        try {
            return $this->render('@bolt/extend/extend.twig', $this->getRenderContext());
        } catch (\Exception $e) {
            return $this->getJsonException($e);
        }
    }
396820
public function getDataFeed($uri = self::ANALYTICS_FEED_URI)
    {
        if ($uri instanceof Query) {
            $uri = $uri->getQueryUrl();
        }
        return parent::getFeed($uri, 'Zend_Gdata_Analytics_DataFeed');
    }
584881
@Override
    public JavaFileObject getOverviewPath() {
        if (overviewpath != null && getFileManager() instanceof StandardJavaFileManager) {
            StandardJavaFileManager fm = (StandardJavaFileManager) getFileManager();
            return fm.getJavaFileObjects(overviewpath).iterator().next();
        }
        return null;
    }
460201
public function aroundGetData(CategoryDataProvider $dataProvider, \Closure $proceed)
    {
        $data = $proceed();

        $currentCategory = $dataProvider->getCurrentCategory();

        if ($currentCategory->getId() !== null && $currentCategory->getLevel() >= 2) {
            $data[$currentCategory->getId()]['facet_config'] = $this->getFilterableAttributeList($currentCategory);
        }

        return $data;
    }
242503
public function getData(&$overview)
    {
        $this->output->writeln("\t" . 'Fetching metrics..');

        // execute the query
        $metrics = 'ga:sessions, ga:users, ga:pageviews, ga:pageviewsPerSession, ga:avgSessionDuration';
        $rows = $this->executeQuery($overview, $metrics);

        // sessions metric
        $visits = is_numeric($rows[0][0]) ? $rows[0][0] : 0;
        $overview->setSessions($visits);

        // users metric
        $visitors = is_numeric($rows[0][1]) ? $rows[0][1] : 0;
        $overview->setUsers($visitors);

        // pageviews metric
        $pageviews = is_numeric($rows[0][2]) ? $rows[0][2] : 0;
        $overview->setPageViews($pageviews);

        // pages per visit metric
        $pagesPerVisit = is_numeric($rows[0][3]) ? $rows[0][3] : 0;
        $overview->setPagesPerSession($pagesPerVisit);

        // avg visit duration metric
        $avgVisitDuration = is_numeric($rows[0][4]) ? $rows[0][4] : 0;
        $overview->setAvgSessionDuration(gmdate('H:i:s', $avgVisitDuration));
    }
996481
public function getData(&$overview)
    {
        // visitor types
        $this->output->writeln("\t" . 'Fetching visitor types..');

        // execute the query
        $metrics = 'ga:percentNewSessions';
        $rows = $this->executeQuery($overview, $metrics);

        // new sessions
        $newUsers = is_array($rows) && isset($rows[0][0]) ? $rows[0][0] : 0;
        $overview->setNewUsers($newUsers);
    }
683082
public function getOverviewAction($id)
    {
        $em = $this->getDoctrine()->getManager();
        /** @var AnalyticsOverviewRepository $analyticsOverviewRepository */
        $analyticsOverviewRepository = $em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview');
        $overview = $analyticsOverviewRepository->find($id);

        // goals data
        $goals = array();
        foreach ($overview->getActiveGoals() as $key => $goal) {
            /* @var AnalyticsGoal $goal */
            $goals[$key]['name'] = $goal->getName();
            $goals[$key]['visits'] = $goal->getVisits();
            $goals[$key]['id'] = $goal->getId();
            $goals[$key]['chartData'] = json_decode($goal->getChartData());
        }

        // overview data
        $overviewData = array(
            'id' => $overview->getId(),
            'chartData' => json_decode($overview->getChartData(), true),
            'chartDataMaxValue' => $overview->getChartDataMaxValue(),
            'title' => $overview->getTitle(),
            'timespan' => $overview->getTimespan(),
            'startOffset' => $overview->getStartOffset(),
            'sessions' => number_format($overview->getSessions()),
            'users' => number_format($overview->getUsers()),
            'pagesPerSession' => round($overview->getPagesPerSession(), 2),
            'avgSessionDuration' => $overview->getAvgSessionDuration(),
            'returningUsers' => number_format($overview->getReturningUsers()),
            'newUsers' => round($overview->getNewUsers(), 2),
            'pageViews' => number_format($overview->getPageViews()),
            'returningUsersPercentage' => $overview->getReturningUsersPercentage(),
            'newUsersPercentage' => $overview->getNewUsersPercentage(),
        );

        // put all data in the return array
        $return = array(
            'responseCode' => 200,
            'overview' => $overviewData,
            'goals' => $goals,
        );

        // return json response
        return new JsonResponse($return, 200, array('Content-Type' => 'application/json'));
    }
1024365
def overviews(self):
        
        overviews = []
        try:
            list_items = self._ad_page_content.select("#overview li")
        except Exception as e:
            if self._debug:
                logging.error(
                    "Error getting overviews. Error message: " + e.args[0])
            return

        for li in list_items:
            overviews.append(li.text)
        return overviews
1259764
public function get(array $metrics = [], ?int $since = null, ?int $until = null): InsightsResponse
    {
        $metrics = $this->isValidMetrics($metrics);

        $request = new InsightsRequest($this->pageToken, $metrics, $since, $until);
        $response = $this->client->get('me/insights', $request->build());

        return new InsightsResponse($response);
    }
53179
public function getData($segments){
		$data=new stdClass;
		$data->error=-1;
		//Check privileges.
		$bau=BAdminUsers::getInstance();
		$data->can_view=$bau->can($this->accessgroup,$this->access_view);
		$data->can_edit=$bau->can($this->accessgroup,$this->access_edit);
		if((!$data->can_view)&&(!$data->can_edit)){
			$data->error=ERR_LOW_PRIVS;
			return $data;
			}

		//Get item
		$classname=$this->itemcollection;
		$itmcoll=$classname::getInstance();
		$data->item=$itmcoll->item_get($segments['id']);
		if(empty($data->item)){
			BLog::addToLog('[MVC.Admin.ModelItemEdit] Could not get item!',LL_ERROR);
			$data->error=1;
			return $data;
			}
		$data->do=BRequest::getString('do');
		BLog::addToLog('[MVC.Admin.ModelItemEdit] do='.$data->do);

		$data->saving=(($data->do=='save')||($data->do=='save_exit'));
		$this->fieldsval=array();
		//TODO: set default fields...

		//
		$this->getfilterdata($data);
		if(($data->saving)&&($data->can_edit)){
			BLog::addToLog('[MVC.Admin.ModelItemEdit] setting fields...');
			if(!$this->itemsetfields($data->item)){
				BLog::addToLog('[MVC.Admin.ModelItemEdit] We have some errors during setting fields.',LL_ERROR);
				BLog::addToLog('[MVC.Admin.ModelItemEdit] errors: '.var_export($this->errors,true),LL_ERROR);
				BLog::addToLog('[MVC.Admin.ModelItemEdit] warnings: '.var_export($this->warnings,true),LL_ERROR);
				$data->errors=$this->errors;
				$data->warnings=$this->warnings;
				$data->error=2;
				return $data;
				}
			if(empty($data->errors)){
				BLog::addToLog('[MVC.Admin.ModelItemEdit] Saving to database...');
				$data->item->saveToDB();
				}
			if($data->do=='save_exit'){
				$data->redirect=$this->url_exit;;
				}
			}
		//

		//
		$data->error=0;
		$data->fieldsval=$this->fieldsval;
		$data->errors=$this->errors;
		$data->warnings=$this->warnings;
		return $data;
		}
199652
public function overview()
    {
        $migrations = $this->getMigrations();
        $dbMigrations = $this->getExecutedMigrations();

        return view('vendor.installer.update.overview', ['numberOfUpdatesPending' => count($migrations) - count($dbMigrations)]);
    }