Add last meter consumption value.

This commit is contained in:
2024-05-04 11:46:42 +02:00
parent f626eb245d
commit c8001590cf
2 changed files with 16 additions and 0 deletions

View File

@@ -109,4 +109,13 @@ function get_year_production(mysqli $db, string $table, $date): array
$sum_result = $db->query($sum_query);
return $sum_result->fetch_assoc();
}
function get_last_value(mysqli $db, string $table, $date): float
{
$value_query = 'SELECT last_value FROM ' . $table . ' WHERE date LIKE "' . $date . '%" ORDER BY date DESC LIMIT 1;';
$value_result = $db->query($value_query);
$data = $value_result->fetch_assoc();
return floatval($data['last_value']) / 1000;
}