public function testBuild() { $expectedResult = ['count' => 'count(main_table.value)']; $this->requestBucket->expects($this->once())->method('getMetrics')->willReturn([$this->metric]); $this->metric->expects($this->once())->method('getType')->willReturn('count'); $metrics = $this->metrics->build($this->requestBucket); $this->assertEquals($expectedResult, $metrics); }
/** * {@inheritdoc} */ public function build(DataProviderInterface $dataProvider, array $dimensions, RequestBucketInterface $bucket, Table $entityIdsTable) { $metrics = $this->metricsBuilder->build($bucket); $select = $dataProvider->getDataSet($bucket, $dimensions, $entityIdsTable); $select->columns($metrics); $select->group(RequestBucketInterface::FIELD_VALUE); return $dataProvider->execute($select); }
/** * {@inheritdoc} */ public function build(DataProviderInterface $dataProvider, array $dimensions, RequestBucketInterface $bucket, Table $entityIdsTable) { /** @var RangeBucket $bucket */ $select = $dataProvider->getDataSet($bucket, $dimensions, $entityIdsTable); $metrics = $this->metricsBuilder->build($bucket); /** @var Select $fullQuery */ $fullQuery = $this->connection->select(); $fullQuery->from(['main_table' => $select], null); $fullQuery = $this->generateCase($fullQuery, $bucket->getRanges()); $fullQuery->columns($metrics); $fullQuery->group(new \Zend_Db_Expr('1')); return $dataProvider->execute($fullQuery); }