test: compare general rank data state

This commit is contained in:
2026-07-26 06:05:06 +00:00
parent d936d93be8
commit fe39241a90
2 changed files with 42 additions and 0 deletions
+16
View File
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace sammo;
use sammo\Enums\RankColumn;
if (PHP_SAPI !== 'cli') {
http_response_code(404);
exit;
@@ -229,6 +231,19 @@ function comparisonTurnStateSnapshot(array $request): array
},
comparisonRowsById('general', 'no', $generalIds),
);
$rankTypes = array_map(
static fn(RankColumn $column): string => $column->value,
RankColumn::cases(),
);
$rankData = $generalIds === []
? []
: iterator_to_array($db->query(
'SELECT general_id AS generalId, nation_id AS nationId, `type`, `value`'
. ' FROM rank_data WHERE general_id IN %li AND `type` IN %ls'
. ' ORDER BY general_id, `type`',
$generalIds,
$rankTypes,
));
$cities = array_map(
static fn(array $row): array => comparisonPickRow(
@@ -412,6 +427,7 @@ function comparisonTurnStateSnapshot(array $request): array
'generalCooldowns' => $generalCooldowns,
],
'generals' => $generals,
'rankData' => $rankData,
'cities' => $cities,
'nations' => $nations,
'diplomacy' => $diplomacy,