get data and save it for the overview

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

        // calculate timespan
        $timespan = $overview->getTimespan() - $overview->getStartOffset();
        if ($timespan <= 1) {
            $extra = array('dimensions' => 'ga:date,ga:hour');
            $start = 2;
        } else {
            if ($timespan <= 7) {
                $extra = array('dimensions' => 'ga:date,ga:hour');
                $start = 2;
            } else {
                if ($timespan <= 31) {
                    $extra = array('dimensions' => 'ga:week,ga:day,ga:date');
                    $start = 3;
                } else {
                    $extra = array('dimensions' => 'ga:isoYearIsoWeek');
                    $start = 1;
                }
            }
        }

        // add segment
        if ($overview->getSegment()) {
            $extra['segment'] = $overview->getSegment()->getQuery();
        }

        $goals = $this->getAllGoals();
        if (!$goals) {
            return;
        }
        $goaldata = array();

        // Create an array with for each goal an entry to create the metric parameter.
        foreach ($goals as $key => $value) {
            ++$key;
            $goaldata[] = array('position' => $key, 'name' => $value->name);
        }

        $metrics = $this->prepareMetrics();

        $rows = $this->requestGoalResults($overview, $metrics[0], $extra);
        // Execute an extra query if there are more than 10 goals to query
        if (count($metrics) > 1) {
            $rows2 = $this->requestGoalResults($overview, $metrics[1], $extra);
            $rows2size = count($rows2);
            for ($i = 0; $i < $rows2size; ++$i) {
                // Merge the results of the extra query data with the previous query data.
                $rows[$i] = array_merge($rows[$i], array_slice($rows2[$i], $start, count($rows2) - $start));
            }
        }

        // Create a result array to be parsed and create Goal objects from
        $goalCollection = array();
        $goaldatasize = count($goaldata);
        for ($i = 0; $i < $goaldatasize; ++$i) {
            $goalEntry = array();
            foreach ($rows as $row) {
                // Create a timestamp for each goal visit (this depends on the timespan of the overview: split per hour, day, week, month)
                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);
                } else {
                    if ($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);
                    } else {
                        if ($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);
                        }
                    }
                }
                $goalEntry[$timestamp] = $row[$i + $start];
            }
            $goalCollection['goal' . $goaldata[$i]['position']]['name'] = $goaldata[$i]['name'];
            $goalCollection['goal' . $goaldata[$i]['position']]['position'] = $goaldata[$i]['position'];
            $goalCollection['goal' . $goaldata[$i]['position']]['visits'] = $goalEntry;
        }

        // Parse the goals and append them to the overview.
        $this->parseGoals($overview, $goalCollection);
    }
1164966
public function overviewAction(
        Request $request,
        FormFactoryInterface $formFactory,
        ExtraFormBuilderInterface $extraFormBuilder
    ) {
        $formName = 'overview';
        $data = $request->request->get($formName);
        $configurationRaw = $data['configuration'];
        $configuration = json_decode($configurationRaw, true);

        $overviewBuilder = $formFactory
            ->createNamedBuilder($formName)
            ->setAction($this->generateUrl('idci_extra_form_editor_overview'))
            ->add('configuration', HiddenType::class, array(
                'data' => $configurationRaw,
            ))
        ;

        $form = $extraFormBuilder
            ->build($configuration, array(), array(), $overviewBuilder)
            ->add('submit', SubmitType::class)
            ->getForm()
        ;

        // The form overview has been submitted
        if (count($data) > 1) {
            $form->handleRequest($request);
            if ($form->isValid()) {
                return new Response('This form was well submitted');
            }
        }

        // Render the form with or without errors
        return $this->render('@IDCIExtraForm/Editor/overview.html.twig', array(
            'form' => $form->createView(),
        ));
    }
301304
public function index()
    {
        if (! config('eyewitness.debug')) {
            return redirect(route('eyewitness.dashboard').'#overview')->withError('Sorry, but you need to enable eyewitness.debug mode to be able to view the debug page');
        }

        // Get all application config
        $config = Config::all();

        // Strip known sensitive config
        $config['services'] = null;
        $config['mail'] = null;
        $config['filesystems']['disks'] = null;

        // Now try to strip anything that might be senstive
        $this->recursive_unset($config, 'key');
        $this->recursive_unset($config, 'secret');
        $this->recursive_unset($config, 'password');

        return view('eyewitness::debug.index')->withEye(app(Eye::class))->withConfig($config);
    }
1180587
public function index()
    {
        return view('eyewitness::dashboard.index')->withEye(app(Eye::class))
                                                  ->withTransformer(new ChartTransformer)
                                                  ->withNotifications(History::orderBy('acknowledged')->orderBy('created_at', 'desc')->get())
                                                  ->withStatuses(Statuses::all())
                                                  ->withQueues(Queue::all())
                                                  ->withSchedulers(Scheduler::all());
    }
1302991
public function getData($options)
    {
        if ($this->checkRequiredParameters($options)) {
            $this->getOrderData($options);
            $this->getShipppingData($options);
            parent::orderDataByDate(false);

            return parent::serializeData();
        } else {
            throw new WidgetException('No params found!', $this->getName());
        }
    }
1053056
protected function getViewData()
    {
        $paginator = $this
            ->grid
            ->getConfig()
            ->getDataProvider()
            ->getPaginator();
        # Laravel 4
        if (method_exists($paginator, 'getFrom')) {
            $from = $paginator->getFrom();
            $to = $paginator->getTo();
            $total = $paginator->getTotal();
        # Laravel 5
        } else {
            $from = $paginator->firstItem();
            $to = $paginator->lastItem();
            $total = $paginator->total();
        }
        return parent::getViewData() + compact('from', 'to', 'total');
    }
723753
public function get_labelled_data() {
        // Delegates all processing to the analysis.
        $result = new \core_analytics\local\analysis\result_file($this->get_modelid(), true, $this->get_options());
        $analysis = new \core_analytics\analysis($this, true, $result);
        $analysis->run();
        return $result->get();
    }
530024
public function saveHistory($status)
    {
        try {
            History::create(['type' => 'custom',
                             'meta' => $this->getSafeName(),
                             'value' => $this->getValue(),
                             'record' => [
                                'status' => $status
                             ],
            ]);
        } catch (Exception $e) {
            $this->eye->logger()->error('Custom witness history save failed', $e, $this->getSafeName());
        }
    }
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));
    }
764260
protected function overviewAction(ServerRequestInterface $request)
    {
        $this->getButtons();
        $demand = Demand::createFromRequest($request);
        $redirectRepository = GeneralUtility::makeInstance(RedirectRepository::class, $demand);
        $count = $redirectRepository->countRedirectsByByDemand();

        $this->view->assignMultiple([
            'redirects' => $redirectRepository->findRedirectsByDemand(),
            'hosts' => $redirectRepository->findHostsOfRedirects(),
            'statusCodes' => $redirectRepository->findStatusCodesOfRedirects(),
            'demand' => $demand,
            'defaultUrl' => GeneralUtility::makeInstance(UrlService::class)->getDefaultUrl(),
            'showHitCounter' => GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('redirects.hitCount'),
            'pagination' => $this->preparePagination($demand, $count),
        ]);
    }
215241
public function getData()
    {
        $serviceRoute = $this->requestStack->getCurrentRequest()
                                           ->get('service');

        // Locate the model definition
        $model = $this->getAnalyticModel($serviceRoute);

        $cacheTime = $model->getCacheTime();
        $cacheKey = $this->getCacheKey($model);

        //Cached data if configured
        if ($cacheTime &&
            !$this->requestStack->getCurrentRequest()->headers->has($this->skipCacheHeaderName) &&
            $cache = $this->cacheProvider->fetch($cacheKey)
        ) {
            return $cache;
        }

        $data = $this->analyticsManager->getData($model, $this->getServiceParameters($model));

        if ($cacheTime) {
            $this->cacheProvider->save($cacheKey, $data, $cacheTime);
        }

        return $data;
    }
852719
public function getAnalyticsViewsForm($withPortfolioSelect = false)
    {
        return new AnalyticsViewsType($this->translator, $this->securityTokenStorage->getToken()->getUser(), $withPortfolioSelect);
    }
1285365
public function getHistorySummary() {

		$history = $this->History();
		$query = new SQLSelect(
			"Term, COUNT(*) AS Frequency, ((COUNT(*) * 100.00) / {$history->count()}) AS FrequencyPercentage, AVG(Time) AS AverageTimeTaken, (Results > 0) AS Results",
			'ExtensibleSearch',
			"ExtensibleSearchPageID = {$this->ID}",
			array(
				'Frequency' => 'DESC',
				'Term' => 'ASC'
			),
			array(
				'Term',
				'Results'
			)
		);

		// These will require display formatting.

		$analytics = ArrayList::create();
		foreach($query->execute() as $result) {
			$result = ArrayData::create(
				$result
			);
			$result->FrequencyPercentage = sprintf('%.2f %%', $result->FrequencyPercentage);
			$result->AverageTimeTaken = sprintf('%.5f', $result->AverageTimeTaken);
			$result->Results = $result->Results ? _t('EXTENSIBLE_SEARCH.TRUE', 'true') : _t('EXTENSIBLE_SEARCH.FALSE', 'false');
			$analytics->push($result);
		}
		return $analytics;
	}
662161
protected void processOverview() {
        if ( options.getOverviewFile() != null ) {
            try {
                rootDoc.setRawCommentText(Files.toString(options.getOverviewFile(), options.getEncoding()));
                defaultProcess(rootDoc, false);
            }
            catch ( IOException e ) {
                printError("Error loading overview from " + options.getOverviewFile() + ": " + e.getLocalizedMessage());
                rootDoc.setRawCommentText("");
            }
        }
    }
388007
def get_context_data(self, **kwargs):
        """"""
        data = super(MetricsListView, self).get_context_data(**kwargs)

        # Metrics organized by category, like so:
        # { <category_name>: [ <slug1>, <slug2>, ... ]}
        data.update({'metrics': get_r().metric_slugs_by_category()})
        return data
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'));
    }
1243897
public function overviewAction()
    {
        $roles = array();

        foreach ($this->acl->getRolePrivileges() as $role => $privileges) {
            $roles[$role][$this->_('Role')]    = $role;
            $roles[$role][$this->_('Parents')] = $privileges[\MUtil_Acl::PARENTS]   ? implode(', ', $privileges[\MUtil_Acl::PARENTS])   : null;
            $roles[$role][$this->_('Allowed')] = $privileges[\Zend_Acl::TYPE_ALLOW] ? implode(', ', $privileges[\Zend_Acl::TYPE_ALLOW]) : null;
            //$roles[$role][$this->_('Denied')]  = $privileges[\Zend_Acl::TYPE_DENY]  ? implode(', ', $privileges[\Zend_Acl::TYPE_DENY])  : null;
            $roles[$role][$this->_('Inherited')] = $privileges[\MUtil_Acl::INHERITED][\Zend_Acl::TYPE_ALLOW] ? implode(', ', $privileges[\MUtil_Acl::INHERITED][\Zend_Acl::TYPE_ALLOW]) : null;
            //$roles[$role][$this->_('Parent denied')]  = $privileges[\MUtil_Acl::INHERITED][\Zend_Acl::TYPE_DENY]  ? implode(', ', $privileges[\MUtil_Acl::INHERITED][\Zend_Acl::TYPE_DENY])  : null;
        }
        ksort($roles);

        $this->html->h2($this->_('Project role overview'));

        $this->_showTable($this->_('Roles'), $roles, true);
    }