mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-03-14 20:21:14 +03: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
1 changed files with 9 additions and 2 deletions
|
@ -25,11 +25,13 @@ TEXT;
|
|||
'feed_3' => ['name' => 'Feed url', 'type' => 'text'],
|
||||
'feed_4' => ['name' => 'Feed url', 'type' => 'text'],
|
||||
'feed_5' => ['name' => 'Feed url', 'type' => 'text'],
|
||||
|
||||
'limit' => self::LIMIT,
|
||||
]
|
||||
];
|
||||
|
||||
public function collectData() {
|
||||
$limit = 10;
|
||||
$limit = (int)($this->getInput('limit') ?: 10);
|
||||
$feeds = [
|
||||
$this->getInput('feed_1'),
|
||||
$this->getInput('feed_2'),
|
||||
|
@ -40,8 +42,13 @@ TEXT;
|
|||
// Remove empty values
|
||||
$feeds = array_filter($feeds);
|
||||
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() {
|
||||
|
|
Loading…
Add table
Reference in a new issue