feat(cloudron): add tirreno package artifacts
- Add CloudronStack/output/CloudronPackages-Artifacts/tirreno/ directory and its contents - Includes package manifest, Dockerfile, source code, documentation, and build artifacts - Add tirreno-1761840148.tar.gz as a build artifact - Add tirreno-cloudron-package-1761841304.tar.gz as the Cloudron package - Include all necessary files for the tirreno Cloudron package This adds the complete tirreno Cloudron package artifacts to the repository.
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tirreno ~ Open source user analytics
|
||||
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
|
||||
*
|
||||
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
||||
* For full copyright and license information, please see the LICENSE
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
|
||||
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
||||
* @link https://www.tirreno.com Tirreno(tm)
|
||||
*/
|
||||
|
||||
namespace Models\Grid\Base;
|
||||
|
||||
class Grid extends \Models\BaseSql {
|
||||
use \Traits\Enrichment\TimeZones;
|
||||
use \Traits\DateRange;
|
||||
|
||||
protected $DB_TABLE_NAME = 'event';
|
||||
|
||||
protected $idsModel = null;
|
||||
protected $apiKey = null;
|
||||
protected $query = null;
|
||||
|
||||
protected function getGrid(?string $ids = null, array $idsParams = []): array {
|
||||
$this->setIds($ids, $idsParams);
|
||||
|
||||
$draw = $this->f3->get('REQUEST.draw');
|
||||
|
||||
$draw = $draw ?? 1;
|
||||
$data = $this->getData();
|
||||
$total = $this->getTotal();
|
||||
|
||||
$params = $this->f3->get('GET');
|
||||
$dateRange = $this->getDatesRange($params);
|
||||
|
||||
return [
|
||||
'data' => $data,
|
||||
'draw' => $draw,
|
||||
'recordsTotal' => $total,
|
||||
'recordsFiltered' => $total,
|
||||
'dateRange' => $dateRange,
|
||||
];
|
||||
}
|
||||
|
||||
public function setIds(?string $ids, array $idsParams): void {
|
||||
$this->query->setIds($ids, $idsParams);
|
||||
}
|
||||
|
||||
protected function getData(): array {
|
||||
[$query, $params] = $this->query->getData();
|
||||
|
||||
$results = $this->execQuery($query, $params);
|
||||
|
||||
$this->convertTimeToUserTimezone($results);
|
||||
$this->calculateCustomParams($results);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
protected function getTotal(): int {
|
||||
[$query, $params] = $this->query->getTotal();
|
||||
|
||||
$results = $this->execQuery($query, $params);
|
||||
|
||||
return $results[0]['count'];
|
||||
}
|
||||
|
||||
protected function convertTimeToUserTimezone(array &$result): void {
|
||||
$this->translateTimeZones($result);
|
||||
}
|
||||
|
||||
protected function calculateCustomParams(array &$result): void {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tirreno ~ Open source user analytics
|
||||
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
|
||||
*
|
||||
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
||||
* For full copyright and license information, please see the LICENSE
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
|
||||
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
||||
* @link https://www.tirreno.com Tirreno(tm)
|
||||
*/
|
||||
|
||||
namespace Models\Grid\Base;
|
||||
|
||||
class Ids extends \Models\BaseSql {
|
||||
protected $DB_TABLE_NAME = 'event';
|
||||
|
||||
private $apiKey = null;
|
||||
|
||||
public function __construct(int $apiKey) {
|
||||
parent::__construct();
|
||||
|
||||
$this->apiKey = $apiKey;
|
||||
}
|
||||
|
||||
public function execute(string $query, array $params): array {
|
||||
$params[':api_key'] = $this->apiKey;
|
||||
|
||||
$data = $this->execQuery($query, $params);
|
||||
$results = array_column($data, 'itemid');
|
||||
|
||||
return count($results) ? $results : [-1];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tirreno ~ Open source user analytics
|
||||
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
|
||||
*
|
||||
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
||||
* For full copyright and license information, please see the LICENSE
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
|
||||
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
||||
* @link https://www.tirreno.com Tirreno(tm)
|
||||
*/
|
||||
|
||||
namespace Models\Grid\Base;
|
||||
|
||||
class Query {
|
||||
use \Traits\Debug;
|
||||
use \Traits\DateRange;
|
||||
|
||||
protected $f3 = null;
|
||||
protected $apiKey = null;
|
||||
protected $ids = null;
|
||||
protected $idsParams = [];
|
||||
protected $itemKey = null;
|
||||
protected $itemId = null;
|
||||
|
||||
protected $defaultOrder = null;
|
||||
protected $dateRangeField = 'event_country.lastseen';
|
||||
|
||||
protected $allowedColumns = [];
|
||||
|
||||
public function __construct(int $apiKey) {
|
||||
$this->f3 = \Base::instance();
|
||||
$this->apiKey = $apiKey;
|
||||
}
|
||||
|
||||
public function setIds(?string $ids, array $idsParams): void {
|
||||
$this->ids = $ids;
|
||||
$this->idsParams = $idsParams;
|
||||
if (count($this->idsParams)) {
|
||||
$this->itemKey = array_keys($this->idsParams)[0];
|
||||
$this->itemId = $this->idsParams[$this->itemKey];
|
||||
}
|
||||
}
|
||||
|
||||
protected function applyOrder(string &$query): void {
|
||||
$request = $this->f3->get('REQUEST');
|
||||
|
||||
$order = $request['order'] ?? [];
|
||||
$columns = $request['columns'] ?? [];
|
||||
|
||||
$orderCondition = $this->defaultOrder;
|
||||
|
||||
if (count($order) && count($columns)) {
|
||||
$orderClauses = [];
|
||||
foreach ($order as $orderData) {
|
||||
$sortDirection = $orderData['dir'] === 'asc' ? 'ASC' : 'DESC';
|
||||
$columnIndex = $orderData['column'];
|
||||
$sortColumn = $columns[$columnIndex]['data'];
|
||||
if (in_array($sortColumn, $this->allowedColumns)) {
|
||||
$orderClauses[] = sprintf('%s %s', $sortColumn, $sortDirection);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($orderClauses)) {
|
||||
$orderCondition = implode(', ', $orderClauses);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderCondition) {
|
||||
$query .= sprintf(' ORDER BY %s', $orderCondition);
|
||||
}
|
||||
}
|
||||
|
||||
protected function applyDateRange(string &$query, array &$queryParams): void {
|
||||
$params = $this->f3->get('GET');
|
||||
$dateRange = $this->getDatesRange($params);
|
||||
|
||||
if ($dateRange) {
|
||||
$searchConditions = (
|
||||
"AND {$this->dateRangeField} >= :start_time
|
||||
AND {$this->dateRangeField} <= :end_time
|
||||
%s"
|
||||
);
|
||||
|
||||
$query = sprintf($query, $searchConditions);
|
||||
$queryParams[':end_time'] = $dateRange['endDate'];
|
||||
$queryParams[':start_time'] = $dateRange['startDate'];
|
||||
}
|
||||
}
|
||||
|
||||
protected function applyLimit(string &$query, array &$queryParams): void {
|
||||
$request = $this->f3->get('REQUEST');
|
||||
|
||||
$start = $request['start'] ?? null;
|
||||
$length = $request['length'] ?? null;
|
||||
|
||||
if (isset($start) && isset($length)) {
|
||||
$query .= ' LIMIT :length OFFSET :start';
|
||||
|
||||
$queryParams[':start'] = $start;
|
||||
$queryParams[':length'] = $length;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getQueryParams(): array {
|
||||
return [':api_key' => $this->apiKey];
|
||||
}
|
||||
|
||||
public function injectIdQuery(string $field, &$params): string {
|
||||
$idsQuery = $this->ids;
|
||||
if ($idsQuery === null || $idsQuery === '') {
|
||||
return '';
|
||||
}
|
||||
$idsParams = $this->idsParams;
|
||||
|
||||
foreach ($idsParams as $key => $value) {
|
||||
if (!array_key_exists($key, $params) || $params[$key] === null) {
|
||||
$params[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return " AND $field IN ($idsQuery)";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user