asdasd
All checks were successful
Deploy / deploy-staging (push) Successful in 6s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-05-01 03:37:41 +02:00
parent 5a154f896b
commit c444ece852
10 changed files with 436 additions and 152 deletions

View File

@@ -430,6 +430,7 @@ final class MiningRepository
'project_key' => $projectKey,
'measured_at' => $payload['measured_at'] ?? null,
'price_currency' => $payload['price_currency'] ?? null,
'fx_fetch_id' => $payload['fx_fetch_id'] ?? null,
]);
$params = [
'project_key' => $projectKey,
@@ -438,6 +439,7 @@ final class MiningRepository
'coins_total' => $payload['coins_total'],
'price_per_coin' => $payload['price_per_coin'],
'price_currency' => $payload['price_currency'],
'fx_fetch_id' => $payload['fx_fetch_id'] ?? null,
'note' => $payload['note'],
'source' => $payload['source'],
'image_path' => $payload['image_path'],
@@ -449,10 +451,10 @@ final class MiningRepository
if ($this->driver === 'pgsql') {
$stmt = $this->pdo->prepare(
'INSERT INTO ' . $this->table('measurements') . ' (
project_key, owner_sub, measured_at, coins_total, price_per_coin, price_currency, note,
project_key, owner_sub, measured_at, coins_total, price_per_coin, price_currency, fx_fetch_id, note,
source, image_path, ocr_raw_text, ocr_confidence, ocr_flags
) VALUES (
:project_key, :owner_sub, :measured_at, :coins_total, :price_per_coin, :price_currency, :note,
:project_key, :owner_sub, :measured_at, :coins_total, :price_per_coin, :price_currency, :fx_fetch_id, :note,
:source, :image_path, :ocr_raw_text, :ocr_confidence, CAST(:ocr_flags AS jsonb)
)
RETURNING *'
@@ -465,10 +467,10 @@ final class MiningRepository
$stmt = $this->pdo->prepare(
'INSERT INTO ' . $this->table('measurements') . ' (
project_key, owner_sub, measured_at, coins_total, price_per_coin, price_currency, note,
project_key, owner_sub, measured_at, coins_total, price_per_coin, price_currency, fx_fetch_id, note,
source, image_path, ocr_raw_text, ocr_confidence, ocr_flags
) VALUES (
:project_key, :owner_sub, :measured_at, :coins_total, :price_per_coin, :price_currency, :note,
:project_key, :owner_sub, :measured_at, :coins_total, :price_per_coin, :price_currency, :fx_fetch_id, :note,
:source, :image_path, :ocr_raw_text, :ocr_confidence, :ocr_flags
)'
);
@@ -497,6 +499,38 @@ final class MiningRepository
}
}
public function setMeasurementFxFetchId(string $projectKey, int $measurementId, ?int $fxFetchId): ?array
{
if ($measurementId <= 0) {
return null;
}
$stmt = $this->pdo->prepare(
'UPDATE ' . $this->table('measurements') . '
SET fx_fetch_id = :fx_fetch_id
WHERE project_key = :project_key AND owner_sub = :owner_sub AND id = :id'
);
$stmt->execute([
'fx_fetch_id' => $fxFetchId,
'project_key' => $projectKey,
'owner_sub' => $this->ownerSub,
'id' => $measurementId,
]);
$fetch = $this->pdo->prepare(
'SELECT * FROM ' . $this->table('measurements') . '
WHERE project_key = :project_key AND owner_sub = :owner_sub AND id = :id LIMIT 1'
);
$fetch->execute([
'project_key' => $projectKey,
'owner_sub' => $this->ownerSub,
'id' => $measurementId,
]);
$row = $fetch->fetch();
return is_array($row) ? $this->normalizeRow($row) : null;
}
public function replaceMeasurementRates(int $measurementId, string $projectKey, array $rates): void
{
$delete = $this->pdo->prepare('DELETE FROM ' . $this->table('measurement_rates') . ' WHERE measurement_id = :measurement_id AND owner_sub = :owner_sub');