Reduce logging in some circumstances to avoid log floods.

This commit is contained in:
Buster Neece 2022-09-17 22:37:20 -05:00
parent 4bf668e4a6
commit 267e87320c
No known key found for this signature in database
GPG Key ID: F1D2E64A0005E80E
3 changed files with 3 additions and 5 deletions

View File

@ -9,7 +9,6 @@ use App\Event\Radio\AnnotateNextSong;
use App\Radio\Backend\Liquidsoap\ConfigWriter;
use Doctrine\ORM\EntityManagerInterface;
use Psr\EventDispatcher\EventDispatcherInterface;
use RuntimeException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
final class Annotations implements EventSubscriberInterface
@ -43,11 +42,11 @@ final class Annotations implements EventSubscriberInterface
public function annotateNextSong(
Entity\Station $station,
bool $asAutoDj = false,
): string {
): string|bool {
$queueRow = $this->queueRepo->getNextToSendToAutoDj($station);
if (null === $queueRow) {
throw new RuntimeException('Queue is empty for station.');
return false;
}
$event = AnnotateNextSong::fromStationQueue($queueRow, $asAutoDj);

View File

@ -21,7 +21,7 @@ final class NextSongCommand extends AbstractCommand
Entity\Station $station,
bool $asAutoDj = false,
array $payload = []
): string {
): string|bool {
return $this->annotations->annotateNextSong(
$station,
$asAutoDj

View File

@ -719,7 +719,6 @@ final class ConfigWriter implements EventSubscriberInterface
$customFunctionBody[] = ' current_time = time()';
$customFunctionBody[] = ' result = (' . implode(' and ', $conditions) . ')';
$customFunctionBody[] = ' log("' . implode(' and ', $conditions) . ' = #{result} (#{current_time})")';
$customFunctionBody[] = ' result';
$customFunctionBody[] = 'end';
$event->appendLines($customFunctionBody);