perf(firewall): use BSON dates and add query indexes
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -90,9 +90,7 @@ class FirewallLogObject implements \JsonSerializable, JsonDeserializable
|
||||
$this->identityId = $data['identityId'] !== null ? (string)$data['identityId'] : null;
|
||||
}
|
||||
if (array_key_exists('timestamp', $data)) {
|
||||
$this->timestamp = $data['timestamp'] !== null
|
||||
? new \DateTimeImmutable($data['timestamp'])
|
||||
: null;
|
||||
$this->timestamp = self::deserializeDate($data['timestamp']);
|
||||
}
|
||||
if (array_key_exists('metadata', $data)) {
|
||||
$this->metadata = $data['metadata'] !== null ? (array)$data['metadata'] : null;
|
||||
@@ -122,6 +120,24 @@ class FirewallLogObject implements \JsonSerializable, JsonDeserializable
|
||||
];
|
||||
}
|
||||
|
||||
private static function deserializeDate(mixed $value): ?\DateTimeImmutable
|
||||
{
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
if ($value instanceof \MongoDB\BSON\UTCDateTime) {
|
||||
return \DateTimeImmutable::createFromMutable($value->toDateTime());
|
||||
}
|
||||
if ($value instanceof \DateTimeImmutable) {
|
||||
return $value;
|
||||
}
|
||||
if ($value instanceof \DateTimeInterface) {
|
||||
return \DateTimeImmutable::createFromInterface($value);
|
||||
}
|
||||
|
||||
return new \DateTimeImmutable((string)$value);
|
||||
}
|
||||
|
||||
// Getters and setters
|
||||
|
||||
public function getId(): ?string
|
||||
|
||||
Reference in New Issue
Block a user