Skip to content

Commit 05491b9

Browse files
lohanidamodarclaude
andcommitted
fix: remove unused useFinal property, fix remaining PHPStan errors
- Remove $useFinal property and setUseFinal() (MergeTree doesn't support FINAL) - Remove buildTableReference $useFinal param - Fix resolveTenantFromMetric mixed type handling - Remove unreachable branch in Database::getTotal() - Remove always-true count check in addBatch Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e99d3a9 commit 05491b9

2 files changed

Lines changed: 8 additions & 18 deletions

File tree

src/Usage/Adapter/ClickHouse.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ class ClickHouse extends SQL
6060

6161
private Client $client;
6262

63-
/** @var bool Whether to use FINAL in SELECT queries to force merge-on-read (tests) */
64-
private bool $useFinal = false;
65-
6663
protected ?string $tenant = null;
6764

6865
protected bool $sharedTables = false;
@@ -129,15 +126,6 @@ public function __construct(
129126
$this->client->setTimeout(30_000); // 30 seconds
130127
}
131128

132-
/**
133-
* Enable or disable using FINAL in SELECT queries.
134-
*/
135-
public function setUseFinal(bool $useFinal): self
136-
{
137-
$this->useFinal = $useFinal;
138-
return $this;
139-
}
140-
141129
/**
142130
* Set the HTTP request timeout in milliseconds.
143131
*
@@ -521,7 +509,7 @@ private function getTableName(): string
521509
* @param bool|null $useFinal Whether to append FINAL clause
522510
* @return string Fully qualified table reference
523511
*/
524-
private function buildTableReference(string $tableName, ?bool $useFinal = null): string
512+
private function buildTableReference(string $tableName): string
525513
{
526514
$escapedTable = $this->escapeIdentifier($this->database) . '.' . $this->escapeIdentifier($tableName);
527515
return $escapedTable;
@@ -1306,9 +1294,7 @@ public function addBatch(array $metrics, int $batchSize = self::INSERT_BATCH_SIZ
13061294
$rows[] = $encoded;
13071295
}
13081296

1309-
if (count($rows) > 0) {
1310-
$this->insert($tableName, $rows);
1311-
}
1297+
$this->insert($tableName, $rows);
13121298
}
13131299

13141300
return true;
@@ -1331,7 +1317,11 @@ private function resolveTenantFromMetric(array $metricData): ?string
13311317
return $tenant;
13321318
}
13331319

1334-
return is_numeric($tenant) ? (string) $tenant : (string) ($tenant ?? '');
1320+
if (is_int($tenant) || is_float($tenant)) {
1321+
return (string) $tenant;
1322+
}
1323+
1324+
return null;
13351325
}
13361326

13371327
/**

src/Usage/Adapter/Database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function getTotal(string $metric, array $queries = []): int
189189
if ($type === 'gauge') {
190190
// For gauge, return the last (most recently inserted) value
191191
$lastResult = end($results);
192-
return $lastResult !== false ? ($lastResult->getValue(0) ?? 0) : 0;
192+
return $lastResult->getValue(0) ?? 0;
193193
}
194194

195195
// For events, SUM all values

0 commit comments

Comments
 (0)