Fetch sitelog through Pg::all()

This commit is contained in:
itismadness
2025-09-10 02:50:03 +00:00
committed by Spine
parent 1291243303
commit 8e7049a87e
2 changed files with 15 additions and 19 deletions

View File

@@ -47,21 +47,17 @@ class SiteLog extends \Gazelle\Base {
public function page(int $limit, int $offset, string $searchTerm): array {
$conf = $this->configure($searchTerm);
$st = $this->pg()->pdo()->prepare("
select id_site_log,
note,
created
from site_log {$conf['where']}
order by id_site_log desc
limit ? offset ?
");
array_push($conf['args'], $limit, $offset);
if ($st === false || !$st->execute($conf['args'])) {
return [];
}
return $this->decorate(
$st->fetchAll(\PDO::FETCH_NUM)
$this->pg()->all("
select id_site_log,
note,
created
from site_log {$conf['where']}
order by id_site_log desc
limit ? offset ?
", ...$conf['args']
)
);
}
@@ -89,13 +85,13 @@ class SiteLog extends \Gazelle\Base {
*/
public function decorate(array $in): array {
$out = [];
foreach ($in as [$id, $message, $created]) {
[$class, $message] = $this->colorize($message);
foreach ($in as $entry) {
[$class, $message] = $this->colorize($entry['note']);
$out[] = [
'id' => $id,
'id' => $entry['id_site_log'],
'class' => $class,
'message' => $message,
'created' => $created,
'created' => $entry['created'],
];
}
return $out;

View File

@@ -29,7 +29,7 @@
<th>{{ paginator.total|number_format }} entries{% if search %} for “{{ search }}{% endif %}</th>
</tr>
{% if sitelog.error %}
<tr class="nobr"><td colspan="2">Search request failed ({{ siteLog.errorMessage }}).</td></tr>
<tr class="nobr"><td colspan="3">Search request failed ({{ siteLog.errorMessage }}).</td></tr>
{% else %}
{% for event in page %}
<tr class="row{{ cycle(['a', 'b'], loop.index0) }}" id="log_{{ event.id }}">
@@ -42,7 +42,7 @@
</td>
</tr>
{% else %}
<tr class="nobr"><td colspan="2">Nothing found!</td></tr>
<tr class="nobr"><td colspan="3">Nothing found!</td></tr>
{% endfor %}
</table>
{{ paginator.linkbox|raw }}