diff --git a/php/generate-listings.php b/php/generate-listings.php index 1e962d6..ed7d662 100644 --- a/php/generate-listings.php +++ b/php/generate-listings.php @@ -4,6 +4,7 @@ require_once "$PROJECT_ROOT/php/utils/logging.php"; class CommunityListing implements JsonSerializable { + public readonly string $id; public readonly string $name; public readonly string $rating; public readonly array $rooms; @@ -11,7 +12,8 @@ /** * @param \CommunityRoom[] $rooms */ - public function __construct(string $name, ?string $rating, array $rooms) { + public function __construct(string $id, string $name, ?string $rating, array $rooms) { + $this->id = $id; $this->name = $name; $this->rating = $rating ?? "unknown"; $this->rooms = $rooms; @@ -28,6 +30,7 @@ public function to_summary(): array { return array( + 'id' => $this->id, 'name' => $this->name, 'rating' => $this->rating, 'rooms' => count($this->rooms) @@ -75,7 +78,8 @@ } } } - $listings[$id] = new CommunityListing( + $listings[] = new CommunityListing( + $id, $listing_props['name'], $listing_props['rating'], $rooms @@ -95,7 +99,8 @@ return $listing->to_summary(); }, $listings_resolved); file_put_contents($LISTING_PROVIDER_LISTING_SUMMARY, json_encode($summaries)); - foreach ($listings_resolved as $id => $listing) { + foreach ($listings_resolved as $listing) { + $id = $listing->id; file_put_contents( "$LISTING_PROVIDER_LISTINGS/$id", json_encode($listing)