[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',
'type' => 'checkbox',
'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(
@ -108,6 +114,8 @@ class KununuBridge extends BridgeAbstract {
$articles = $section->find('article')
or returnServerError('Unable to find articles!');
$limit = $this->getInput('limit') ?: 0;
// Go through all articles
foreach($articles as $article) {
@ -141,6 +149,8 @@ class KununuBridge extends BridgeAbstract {
$this->items[] = $item;
if ($limit > 0 && count($this->items) >= $limit) break;
}
}