mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
[FeedMerge] fix bugs (#2854)
* [FeedMerge] fix: sort items by timestamp descending * [FeedMerge] fix: fetch 10 most recent items This fixes a bug where the bridge e.g. fetched 10 items from the first feed and then nothing from the rest
This commit is contained in:
parent
7dc3449207
commit
a166899633
@ -25,11 +25,13 @@ TEXT;
|
|||||||
'feed_3' => ['name' => 'Feed url', 'type' => 'text'],
|
'feed_3' => ['name' => 'Feed url', 'type' => 'text'],
|
||||||
'feed_4' => ['name' => 'Feed url', 'type' => 'text'],
|
'feed_4' => ['name' => 'Feed url', 'type' => 'text'],
|
||||||
'feed_5' => ['name' => 'Feed url', 'type' => 'text'],
|
'feed_5' => ['name' => 'Feed url', 'type' => 'text'],
|
||||||
|
|
||||||
|
'limit' => self::LIMIT,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
public function collectData() {
|
public function collectData() {
|
||||||
$limit = 10;
|
$limit = (int)($this->getInput('limit') ?: 10);
|
||||||
$feeds = [
|
$feeds = [
|
||||||
$this->getInput('feed_1'),
|
$this->getInput('feed_1'),
|
||||||
$this->getInput('feed_2'),
|
$this->getInput('feed_2'),
|
||||||
@ -40,8 +42,13 @@ TEXT;
|
|||||||
// Remove empty values
|
// Remove empty values
|
||||||
$feeds = array_filter($feeds);
|
$feeds = array_filter($feeds);
|
||||||
foreach ($feeds as $feed) {
|
foreach ($feeds as $feed) {
|
||||||
$this->collectExpandableDatas($feed, $limit);
|
// Fetch all items from the feed
|
||||||
|
$this->collectExpandableDatas($feed);
|
||||||
}
|
}
|
||||||
|
// Sort by timestamp descending
|
||||||
|
usort($this->items, fn($a, $b) => $b['timestamp'] <=> $a['timestamp']);
|
||||||
|
// Grab the first $limit items
|
||||||
|
$this->items = array_slice($this->items, 0, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIcon() {
|
public function getIcon() {
|
||||||
|
Loading…
Reference in New Issue
Block a user