Skip to content

Commit

Permalink
Update AnalyticsDatasource.php
Browse files Browse the repository at this point in the history
Signed-off-by: Rello <Rello@users.noreply.github.com>
  • Loading branch information
Rello committed Jul 3, 2024
1 parent d83fc2a commit 136d421
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions lib/Analytics/AnalyticsDatasource.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
use OCP\IL10N;
use Psr\Log\LoggerInterface;

class AnalyticsDatasource implements IDatasource
{
class AnalyticsDatasource implements IDatasource {
private LoggerInterface $logger;
private IL10N $l10n;
private TableService $tableService;
Expand All @@ -43,8 +42,7 @@ public function __construct(
ColumnService $columnService,
RowService $rowService,
?string $userId
)
{
) {
$this->l10n = $l10n;
$this->logger = $logger;
$this->tableService = $tableService;
Expand All @@ -57,16 +55,14 @@ public function __construct(
/**
* @return string Display Name of the datasource
*/
public function getName(): string
{
public function getName(): string {
return $this->l10n->t('Nextcloud Tables');
}

/**
* @return int 2 digit unique datasource id
*/
public function getId(): int
{
public function getId(): int {
return 55;
}

Expand Down Expand Up @@ -96,8 +92,7 @@ public function getId(): int
* @throws NotFoundError
* @throws PermissionError
*/
public function getTemplate(): array
{
public function getTemplate(): array {
$tableString = '';
$template = [];
$tables = [];
Expand Down Expand Up @@ -143,8 +138,7 @@ public function getTemplate(): array
* @throws DoesNotExistException
* @throws MultipleObjectsReturnedException
*/
public function readData($option): array
{
public function readData($option): array {
// get the ids which come in the format tableId:viewId
$ids = explode(':', $option['tableId']);
$this->userId = $option['user_id'];
Expand Down Expand Up @@ -182,13 +176,8 @@ public function readData($option): array
}
unset($rows);

return [
'header' => $header,
'dimensions' => array_slice($header, 0, count($header) - 1),
'data' => $data,
//'rawdata' => $data,
'error' => 0,
];
return ['header' => $header, 'dimensions' => array_slice($header, 0, count($header) - 1), 'data' => $data, //'rawdata' => $data,
'error' => 0,];
}

/**
Expand All @@ -206,8 +195,7 @@ public function readData($option): array
* @throws NotFoundError
* @throws PermissionError
*/
private function getData(int $nodeId, ?int $limit, ?int $offset, ?string $nodeType = null): array
{
private function getData(int $nodeId, ?int $limit, ?int $offset, ?string $nodeType = null): array {
if ($nodeType === 'view') {
$columns = $this->columnService->findAllByView($nodeId, $this->userId);
$rows = $this->rowService->findAllByView($nodeId, $this->userId, $limit, $offset);
Expand Down Expand Up @@ -260,8 +248,7 @@ private function getData(int $nodeId, ?int $limit, ?int $offset, ?string $nodeTy
* @param array $row
* @return array
*/
private function minimizeRow(array $selectedColumns, array $row): array
{
private function minimizeRow(array $selectedColumns, array $row): array {
$rowMinimized = [];
foreach ($selectedColumns as $selectedColumn) {
if ((int)$selectedColumn) {
Expand Down

0 comments on commit 136d421

Please sign in to comment.