blob: 81eccfb259d3e17b489d02cd75d2ae985b0ab9ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<?php
namespace Digitigrade\Timeline;
use Digitigrade\Db;
use Digitigrade\Model\Note;
class GlobalTimeline extends Timeline {
protected function getItems(int $limit, int $offset): array {
$db = Db::getInstance()->getPdo();
$stmt = $db->prepare(<<<END
SELECT note.id FROM note LEFT JOIN note_privacy ON note_privacy.note_id = note.id
WHERE note_privacy.scope = 'public' AND note_privacy.indexable = true AND note.deleted = false
ORDER BY note.created DESC LIMIT ? OFFSET ?
END);
$stmt->execute([$limit, $offset]);
$ids = $stmt->fetchAll(\PDO::FETCH_COLUMN, 0);
return array_map(fn($id) => new TimelineItem(Note::find($id)), $ids);
}
}
|