[KununuBridge] Add feed item limit

This bridge currently takes a very long time to process
all news items on the page, when in many cases only one
or two had been added since the last check.

This commit adds a new parameter 'limit', which defines
the maximum number of items to add to the feed. This is
an optional paramter that defaults to 3.
This commit is contained in:
logmanoriginal 2019-11-01 15:27:35 +01:00
parent c0df9815c7
commit 50eee7e7b3

View file

@ -34,6 +34,12 @@ class KununuBridge extends BridgeAbstract {
'name' => 'Include benefits', 'name' => 'Include benefits',
'type' => 'checkbox', 'type' => 'checkbox',
'title' => 'Activate to include benefits in the feed' 'title' => 'Activate to include benefits in the feed'
),
'limit' => array(
'name' => 'Limit',
'type' => 'number',
'defaultValue' => 3,
'title' => "Maximum number of items to return in the feed.\n0 = unlimited"
) )
), ),
array( array(
@ -108,6 +114,8 @@ class KununuBridge extends BridgeAbstract {
$articles = $section->find('article') $articles = $section->find('article')
or returnServerError('Unable to find articles!'); or returnServerError('Unable to find articles!');
$limit = $this->getInput('limit') ?: 0;
// Go through all articles // Go through all articles
foreach($articles as $article) { foreach($articles as $article) {
@ -141,6 +149,8 @@ class KununuBridge extends BridgeAbstract {
$this->items[] = $item; $this->items[] = $item;
if ($limit > 0 && count($this->items) >= $limit) break;
} }
} }