Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display: Fix for updating detail of an alert when submitting the end #2714

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions lib/Entity/DisplayEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
]
);
}
Expand All @@ -154,7 +155,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(
Expand All @@ -165,17 +166,21 @@ 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(`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,
'eventTypeId' => $eventTypeId,
'refId' => $refId,
'detail' => $detail,
]
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Xmds/Soap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3201,8 +3201,8 @@ private function createDisplayAlert(\DomElement $alertNode)
$displayEvent = $this->displayEventFactory->createEmpty();
$eventTypeId = $displayEvent->getEventIdFromString($eventType);
empty($refId)
? $displayEvent->eventEnd($this->display->displayId, $eventTypeId, $date)
: $displayEvent->eventEndByReference($this->display->displayId, $eventTypeId, $refId);
? $displayEvent->eventEnd($this->display->displayId, $eventTypeId, $detail, $date)
: $displayEvent->eventEndByReference($this->display->displayId, $eventTypeId, $refId, $detail);
mgbaybay marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Loading