From 513b2097b7f366e5a4a9ccf3568307bf0a793af7 Mon Sep 17 00:00:00 2001 From: mgbaybay Date: Fri, 23 Aug 2024 15:57:03 +0800 Subject: [PATCH 1/3] Display: Update detail of an alert when submitting the end --- lib/Entity/DisplayEvent.php | 8 ++++++-- lib/Xmds/Soap.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Entity/DisplayEvent.php b/lib/Entity/DisplayEvent.php index 094bfc60dd..ff0baabc1e 100644 --- a/lib/Entity/DisplayEvent.php +++ b/lib/Entity/DisplayEvent.php @@ -154,7 +154,7 @@ public function eventEnd(int $displayId, int $eventTypeId = 1, ?int $date = null * @param int|null $date * @return void */ - public function eventEndByReference(int $displayId, int $eventTypeId, int $refId, ?int $date = null): void + public function eventEndByReference(int $displayId, int $eventTypeId, int $refId, string $detail = null, ?int $date = null): void { $this->getLog()->debug( sprintf( @@ -165,8 +165,11 @@ public function eventEndByReference(int $displayId, int $eventTypeId, int $refId ) ); + // When updating the event end, concatenate the end message to the current message $this->getStore()->update( - 'UPDATE `displayevent` SET `end` = :toDt + 'UPDATE `displayevent` SET + `end` = :toDt, + `detail` = CONCAT_WS(". ", NULLIF(CONCAT_WS(".", NULLIF(`detail`, "")), ""), :detail) WHERE displayId = :displayId AND `end` IS NULL AND eventTypeId = :eventTypeId @@ -176,6 +179,7 @@ public function eventEndByReference(int $displayId, int $eventTypeId, int $refId 'displayId' => $displayId, 'eventTypeId' => $eventTypeId, 'refId' => $refId, + 'detail' => $detail, ] ); } diff --git a/lib/Xmds/Soap.php b/lib/Xmds/Soap.php index d84371f867..04a85e2492 100644 --- a/lib/Xmds/Soap.php +++ b/lib/Xmds/Soap.php @@ -3202,7 +3202,7 @@ private function createDisplayAlert(\DomElement $alertNode) $eventTypeId = $displayEvent->getEventIdFromString($eventType); empty($refId) ? $displayEvent->eventEnd($this->display->displayId, $eventTypeId, $date) - : $displayEvent->eventEndByReference($this->display->displayId, $eventTypeId, $refId); + : $displayEvent->eventEndByReference($this->display->displayId, $eventTypeId, $refId, $detail); } } } From 2cb6e44d139dc89470a30666bf40eb4b4f668ba4 Mon Sep 17 00:00:00 2001 From: mgbaybay Date: Fri, 23 Aug 2024 21:27:01 +0800 Subject: [PATCH 2/3] Display: Update SQL query --- lib/Entity/DisplayEvent.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Entity/DisplayEvent.php b/lib/Entity/DisplayEvent.php index ff0baabc1e..ca056dd589 100644 --- a/lib/Entity/DisplayEvent.php +++ b/lib/Entity/DisplayEvent.php @@ -167,13 +167,13 @@ public function eventEndByReference(int $displayId, int $eventTypeId, int $refId // When updating the event end, concatenate the end message to the current message $this->getStore()->update( - 'UPDATE `displayevent` SET + "UPDATE `displayevent` SET `end` = :toDt, - `detail` = CONCAT_WS(". ", NULLIF(CONCAT_WS(".", NULLIF(`detail`, "")), ""), :detail) + `detail` = CONCAT_WS('. ', NULLIF(`detail`, ''), :detail) WHERE displayId = :displayId AND `end` IS NULL AND eventTypeId = :eventTypeId - AND refId = :refId', + AND refId = :refId", [ 'toDt' => $date ?? Carbon::now()->format('U'), 'displayId' => $displayId, From 1316ed804f13d8e31e0b78dd8fa802a226cea70e Mon Sep 17 00:00:00 2001 From: mgbaybay Date: Fri, 23 Aug 2024 21:46:55 +0800 Subject: [PATCH 3/3] Display: Include detail when updating event end --- lib/Entity/DisplayEvent.php | 7 ++++--- lib/Xmds/Soap.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Entity/DisplayEvent.php b/lib/Entity/DisplayEvent.php index ca056dd589..2c29000200 100644 --- a/lib/Entity/DisplayEvent.php +++ b/lib/Entity/DisplayEvent.php @@ -123,7 +123,7 @@ private function edit(): void * @param int $eventTypeId * @return void */ - public function eventEnd(int $displayId, int $eventTypeId = 1, ?int $date = null): void + public function eventEnd(int $displayId, int $eventTypeId = 1, string $detail = null, ?int $date = null): void { $this->getLog()->debug( sprintf( @@ -134,14 +134,15 @@ public function eventEnd(int $displayId, int $eventTypeId = 1, ?int $date = null ); $this->getStore()->update( - 'UPDATE `displayevent` SET `end` = :toDt + "UPDATE `displayevent` SET `end` = :toDt, `detail` = CONCAT_WS('. ', NULLIF(`detail`, ''), :detail) WHERE displayId = :displayId AND `end` IS NULL - AND eventTypeId = :eventTypeId', + AND eventTypeId = :eventTypeId", [ 'toDt' => $date ?? Carbon::now()->format('U'), 'displayId' => $displayId, 'eventTypeId' => $eventTypeId, + 'detail' => $detail, ] ); } diff --git a/lib/Xmds/Soap.php b/lib/Xmds/Soap.php index 04a85e2492..8c1f843abe 100644 --- a/lib/Xmds/Soap.php +++ b/lib/Xmds/Soap.php @@ -3201,7 +3201,7 @@ private function createDisplayAlert(\DomElement $alertNode) $displayEvent = $this->displayEventFactory->createEmpty(); $eventTypeId = $displayEvent->getEventIdFromString($eventType); empty($refId) - ? $displayEvent->eventEnd($this->display->displayId, $eventTypeId, $date) + ? $displayEvent->eventEnd($this->display->displayId, $eventTypeId, $detail, $date) : $displayEvent->eventEndByReference($this->display->displayId, $eventTypeId, $refId, $detail); } }