From 542e50b6357ae36a8b57905d935990f55d65c50c Mon Sep 17 00:00:00 2001 From: Jonathan Danse Date: Mon, 20 Jul 2026 17:25:14 +0200 Subject: [PATCH] feat(company): serialize employees timeframes to topcompanies_prs.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Company::toArray() now embeds the full `employees` map — login → [{ start_date, end_date }, …] — sourced from var/data/companies.json. Traces already loaded this to attribute each PR to the company employing the author at merge time; it just was not propagated to the JSON consumed by the front. Publishing it enables the front to render a proper members table (entry/departure per period, still-active flag, multiple periods per person) instead of relying on the ad-hoc `contributors` list, which is the derived set of PR authors — a different (and noisier) population. The docblock is widened to `array` because the shape now nests `employees[].time_frames[]`; phpstan is happy and the callers only consume the whole array via json_encode. Co-Authored-By: Claude Opus 4.7 --- src/DTO/Company.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/DTO/Company.php b/src/DTO/Company.php index 9f8a61b..771bef0 100644 --- a/src/DTO/Company.php +++ b/src/DTO/Company.php @@ -58,7 +58,7 @@ private static function slugify(string $value): string } /** - * @return array|float|int|string|string[]> + * @return array */ public function toArray(bool $rankByContributions): array { @@ -79,6 +79,17 @@ public function toArray(bool $rankByContributions): array 'avatar_url' => $this->avatarUrl, 'html_url' => $this->htmlUrl, 'contributors' => array_values(array_unique($this->contributors)), + 'employees' => array_map(function (Employee $employee): array { + return [ + 'login' => $employee->login, + 'time_frames' => array_map(function (TimeFrame $timeFrame): array { + return [ + 'start_date' => $timeFrame->startTime->format('Y-m-d'), + 'end_date' => $timeFrame->endTime?->format('Y-m-d'), + ]; + }, $employee->timeFrames), + ]; + }, $this->employees), ]; } }