Skip to content

Commit

Permalink
[KununuBridge] Add feed item limit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
logmanoriginal committed Nov 1, 2019
1 parent c0df981 commit 50eee7e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bridges/KununuBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -108,6 +114,8 @@ public function collectData(){
$articles = $section->find('article')
or returnServerError('Unable to find articles!');

$limit = $this->getInput('limit') ?: 0;

// Go through all articles
foreach($articles as $article) {

Expand Down Expand Up @@ -141,6 +149,8 @@ public function collectData(){

$this->items[] = $item;

if ($limit > 0 && count($this->items) >= $limit) break;

}
}

Expand Down

0 comments on commit 50eee7e

Please sign in to comment.