station search using ogn registration

This commit is contained in:
Per Qvarforth 2022-02-26 13:11:11 +00:00
parent 026b15f252
commit 08878eab81
3 changed files with 15 additions and 11 deletions

View File

@ -197,20 +197,24 @@ class StationRepository extends ModelRepository
}
$pdo = PDOConnection::getInstance();
$stmt = $pdo->prepare(
'select * from station
where latest_confirmed_packet_timestamp is not null
and latest_confirmed_packet_timestamp > ?
and (source_id != 5 or latest_confirmed_packet_timestamp > ?)
and name ilike ?
$stmt = $pdo->prepare('
select s.*
from station s
left outer join ogn_device d on d.device_id = s.latest_ogn_sender_address
where s.latest_confirmed_packet_timestamp is not null
and s.latest_confirmed_packet_timestamp > ?
and (s.source_id != 5 or s.latest_confirmed_packet_timestamp > ?)
and (s.name ilike ? or d.registration ilike ? or d.cn ilike ?)
order by name
limit ? offset ?'
);
$stmt->bindValue(1, (time() - $activeDuringLatestNumberOfSeconds));
$stmt->bindValue(2, (time() - (60*60*24))); // OGN data should be deleted after 24h, but just to be safe we avoid including older data when searching
$stmt->bindValue(3, "$q%");
$stmt->bindValue(4, $limit);
$stmt->bindValue(5, $offset);
$stmt->bindValue(4, "$q%");
$stmt->bindValue(5, "$q%");
$stmt->bindValue(6, $limit);
$stmt->bindValue(7, $offset);
$stmt->execute();
$records = $stmt->fetchAll(PDO::FETCH_ASSOC);

View File

@ -56,7 +56,7 @@
</td>
<td>
<?php if ($foundStation->sourceId == 5 && $foundStation->getOgnDevice() !== null) : ?>
<div style="width: 100px; display: inline-block;">Registration:</div><?php echo htmlspecialchars($foundStation->getOgnDevice()->registration); ?><br/>
<div style="width: 100px; display: inline-block;">Registration:</div><?php echo htmlspecialchars($foundStation->getOgnDevice()->registration); ?> <?php echo $foundStation->getOgnDevice()->cn ? '[' .htmlspecialchars($foundStation->getOgnDevice()->cn) . ']' : ''; ?><br/>
<div style="width: 100px; display: inline-block;">Aircraft Model:</div><?php echo htmlspecialchars($foundStation->getOgnDevice()->aircraftModel); ?>
<?php else : ?>
<?php $latestPacket = PacketRepository::getInstance()->getObjectById($foundStation->latestPacketId, $foundStation->latestPacketTimestamp); ?>

View File

@ -78,7 +78,7 @@
</td>
<td>
<?php if ($foundStation->sourceId == 5 && $foundStation->getOgnDevice() !== null) : ?>
<div style="width: 100px; display: inline-block;">Registration:</div><?php echo htmlspecialchars($foundStation->getOgnDevice()->registration); ?><br/>
<div style="width: 100px; display: inline-block;">Registration:</div><?php echo htmlspecialchars($foundStation->getOgnDevice()->registration); ?> <?php echo $foundStation->getOgnDevice()->cn ? '[' .htmlspecialchars($foundStation->getOgnDevice()->cn) . ']' : ''; ?><br/>
<div style="width: 100px; display: inline-block;">Aircraft Model:</div><?php echo htmlspecialchars($foundStation->getOgnDevice()->aircraftModel); ?>
<?php else : ?>
<?php $latestPacket = PacketRepository::getInstance()->getObjectById($foundStation->latestPacketId, $foundStation->latestPacketTimestamp); ?>