Merge branch 'dev'

dev
gravel 1 year ago
commit e0c5c21967
Signed by: gravel
GPG Key ID: C0538F3C906B308F

@ -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)

Loading…
Cancel
Save