Merge branch 'dev'

dev
gravel 2 years ago
commit e0c5c21967
Signed by: gravel
GPG Key ID: C0538F3C906B308F

@ -4,6 +4,7 @@
require_once "$PROJECT_ROOT/php/utils/logging.php"; require_once "$PROJECT_ROOT/php/utils/logging.php";
class CommunityListing implements JsonSerializable { class CommunityListing implements JsonSerializable {
public readonly string $id;
public readonly string $name; public readonly string $name;
public readonly string $rating; public readonly string $rating;
public readonly array $rooms; public readonly array $rooms;
@ -11,7 +12,8 @@
/** /**
* @param \CommunityRoom[] $rooms * @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->name = $name;
$this->rating = $rating ?? "unknown"; $this->rating = $rating ?? "unknown";
$this->rooms = $rooms; $this->rooms = $rooms;
@ -28,6 +30,7 @@
public function to_summary(): array { public function to_summary(): array {
return array( return array(
'id' => $this->id,
'name' => $this->name, 'name' => $this->name,
'rating' => $this->rating, 'rating' => $this->rating,
'rooms' => count($this->rooms) 'rooms' => count($this->rooms)
@ -75,7 +78,8 @@
} }
} }
} }
$listings[$id] = new CommunityListing( $listings[] = new CommunityListing(
$id,
$listing_props['name'], $listing_props['name'],
$listing_props['rating'], $listing_props['rating'],
$rooms $rooms
@ -95,7 +99,8 @@
return $listing->to_summary(); return $listing->to_summary();
}, $listings_resolved); }, $listings_resolved);
file_put_contents($LISTING_PROVIDER_LISTING_SUMMARY, json_encode($summaries)); 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( file_put_contents(
"$LISTING_PROVIDER_LISTINGS/$id", "$LISTING_PROVIDER_LISTINGS/$id",
json_encode($listing) json_encode($listing)

Loading…
Cancel
Save