Результаты опроса.

@param  AnalyticsServiceContract  $analyticsService
@param  int  $id

@return ResultResponseContract

@throws Throwable
545749
public function getPollResult(
        AnalyticsServiceContract $analyticsService,
        int $id = 0
    ): ResultResponseContract {
        $item = $analyticsService->getItemById(
            $id,
            [
                'relations' => ['options'],
            ]
        );

        return $this->app->make(ResultResponseContract::class, compact('item'));
    }
1018047
public function update(CommentsServiceContract $commentsService, SaveCommentRequestContract $request, int $id = 0): SaveResponseContract
    {
        return $this->save($commentsService, $request, $id);
    }
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();
    }
668467
public function delete($accountId, $filterId, $optParams = array())
  {
    $params = array('accountId' => $accountId, 'filterId' => $filterId);
    $params = array_merge($params, $optParams);
    return $this->call('delete', array($params), "Google_Service_Analytics_Filter");
  }
1161332
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (null === $this->em) {
            $this->em = $this->getContainer()->get('doctrine.orm.entity_manager');
        }

        $configRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig');

        $configId = $input->getArgument('config') ? $input->getArgument('config') : false;

        try {
            $configRepository->flushConfig($configId);
            $output->writeln('<fg=green>Data flushed</fg=green>');
        } catch (\Exception $e) {
            $output->writeln('<fg=red>'.$e->getMessage().'</fg=red>');
        }
    }
282294
public function getAnalysis($projectUuid, $analysesNumber)
    {
        $request = $this->client->createRequest('GET', sprintf('/api/projects/%s/analyses/%s', $projectUuid, $analysesNumber));

        return $this->serializer->deserialize(
            (string) $this->send($request)->getBody(),
            'SensioLabs\Insight\Sdk\Model\Analysis',
            'xml'
        );
    }
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'));
    }
1332596
protected function getProfileIdByTrackingId(&$analytics, $tracking_id)
	{
		$accounts = $analytics->management_accounts->listManagementAccounts();
		
		foreach ($accounts->getItems() as $item)
		{
			$account_id = $item->getId();
			if ($account_id != $tracking_id) continue;
			
			$properties = $analytics->management_webproperties->listManagementWebproperties($account_id);
			
			if (sizeof($properties->getItems()) > 0)
			{
				$items = $properties->getItems();
				$first_property_id = $items[0]->getId();
				
				$profiles = $analytics->management_profiles
					->listManagementProfiles($account_id, $first_property_id);
				
				if (sizeof($profiles->getItems()) > 0)
				{
					$items = $profiles->getItems();
					return $items[0]->getId();
				}
			}
		}
		
		return null;
	}
1318422
public function edit(
        ItemsServiceContract $resourceService,
        int $id = 0
    ): FormResponseContract {
        $item = $resourceService->getItemById($id);

        return $this->app->make(
            FormResponseContract::class,
            [
                'data' => compact('item'),
            ]
        );
    }
158915
public function trans($id, array $parameters = [], $domain = null, $locale = null)
    {
        if (null === $domain) {
            $domain = 'messages';
        }

        $format = $this->getCatalogue($locale)->get((string) $id, $domain);

        if ($format instanceof Closure) {
            // @codeCoverageIgnoreStart
            try {
                $count = (new ReflectionFunction($format))->getNumberOfRequiredParameters();
            } catch (ReflectionException $exception) {
                $count = 0;
            }
            // @codeCoverageIgnoreEnd

            return $format(
                ...array_values($parameters),
                ...array_fill(0, max(0, $count - count($parameters)), null)
            );
        }

        return parent::trans($id, $parameters, $domain, $locale);
    }
1352972
public function process(ContainerBuilder $container)
    {
        $services = [];
        $finder = Finder::create()
                        ->files()
                        ->in(Graviton::getBundleScanDir())
                        ->path('/\/analytics\//i')
                        ->name('*.json')
                        ->notName('_*')
                        ->notName('*.pipeline.*')
                        ->sortByName();

        foreach ($finder as $file) {
            $key = $file->getFilename();
            $data = json_decode($file->getContents(), true);
            if (json_last_error()) {
                throw new InvalidConfigurationException(
                    sprintf('Analytics file: %s could not be loaded due to error: %s', $key, json_last_error_msg())
                );
            }

            if (isset($data['route']) && !empty($data['route'])) {
                $services[$data['route']] = $data;
            } else {
                $services[] = $data;
            }
        }

        $container->setParameter('analytics.services', $services);
    }
135974
private function set($type, $id)
    {
        if (isset($this->definedTypes[$type])) {
            return;
        }

        // is this already a type/class that is known to match multiple services?
        if (isset($this->ambiguousServiceTypes[$type])) {
            $this->ambiguousServiceTypes[$type][] = $id;

            return;
        }

        // check to make sure the type doesn't match multiple services
        if (!isset($this->types[$type]) || $this->types[$type] === $id) {
            $this->types[$type] = $id;

            return;
        }

        // keep an array of all services matching this type
        if (!isset($this->ambiguousServiceTypes[$type])) {
            $this->ambiguousServiceTypes[$type] = array($this->types[$type]);
            unset($this->types[$type]);
        }
        $this->ambiguousServiceTypes[$type][] = $id;
    }
582062
protected function setAnalyticsContent($responseContent, array $analyticsContent)
    {
        foreach ($analyticsContent as $id => $content) {
            if (!$content) {
                continue;
            }

            $responseContent = preg_replace(
                self::$positions[$id]['regex'],
                sprintf(self::$positions[$id]['sprintf'], $content),
                $responseContent
            );
        }

        return $responseContent;
    }
1122291
public function onResponse(FilterResponseEvent $event)
    {
        if ($this->preview
            || 0 !== strpos($event->getResponse()->headers->get('Content-Type'), 'text/html')
            || null === $this->requestAnalyzer->getPortalInformation()
        ) {
            return;
        }

        $portalUrl = $this->requestAnalyzer->getAttribute('urlExpression');

        $analyticsArray = $this->analyticsRepository->findByUrl(
            $portalUrl,
            $this->requestAnalyzer->getPortalInformation()->getWebspaceKey(),
            $this->environment
        );

        $analyticsContent = [];
        foreach ($analyticsArray as $analytics) {
            $analyticsContent = $this->generateAnalyticsContent($analyticsContent, $analytics);
        }

        $response = $event->getResponse();
        $response->setContent($this->setAnalyticsContent($response->getContent(), $analyticsContent));
    }
197539
protected function initService($id, array $args = null) {
		$reflection = $this->getReflectionById($id);
		
		if ($reflection === null) {
			throw new Exceptions\ServiceNotFound('Unable to found the service "' . $id . '"');
		}
		
		if ($args === null) {
			return $reflection->newInstance();
		}

		return $reflection->newInstanceArgs($args);
	}
537361
protected void trackServiceSession(final String id, final Service service, final boolean onlyTrackMostRecentSession) {
        update();
        service.setPrincipal(getRoot().getAuthentication().getPrincipal().getId());
        if (onlyTrackMostRecentSession) {
            val path = normalizePath(service);
            val existingServices = this.services.values();
            existingServices.stream().filter(existingService -> path.equals(normalizePath(existingService))).findFirst().ifPresent(existingServices::remove);
        }
        this.services.put(id, service);
    }
646406
public function callResult($id, $data = array()) {
        return $this->send(json_encode(array(WAMP::MSG_CALL_RESULT, $id, $data)));
    }