mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2024-12-23 03:19:00 +00:00
Filtering works properly (Fix #5)
This commit is contained in:
parent
03063fea23
commit
2262df4dca
@ -97,10 +97,10 @@ class PatchtesterModelPulls extends JModelList
|
|||||||
protected function populateState($ordering = null, $direction = null)
|
protected function populateState($ordering = null, $direction = null)
|
||||||
{
|
{
|
||||||
// Load the filter state.
|
// Load the filter state.
|
||||||
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
|
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '');
|
||||||
$this->setState('filter.search', $search);
|
$this->setState('filter.search', $search);
|
||||||
|
|
||||||
$searchId = $this->getUserStateFromRequest($this->context . '.filter.searchid', 'filter_searchid');
|
$searchId = $this->getUserStateFromRequest($this->context . '.filter.searchid', 'filter_searchid', '');
|
||||||
$this->setState('filter.searchid', $searchId);
|
$this->setState('filter.searchid', $searchId);
|
||||||
|
|
||||||
// Load the parameters.
|
// Load the parameters.
|
||||||
@ -167,11 +167,13 @@ class PatchtesterModelPulls extends JModelList
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$cacheFile = JPATH_CACHE . '/patchtester-page-' . $this->getPagination()->pagesCurrent . '.json';
|
$cacheFile = JPATH_CACHE . '/patchtester-page-' . $this->getPagination()->pagesCurrent . '.json';
|
||||||
$params = $this->getState('params');
|
$params = $this->getState('params');
|
||||||
|
$searchId = $this->getState('filter.searchid');
|
||||||
|
$searchWord = $this->getState('filter.search');
|
||||||
|
|
||||||
// Check if caching is enabled
|
// Check if caching is enabled or that we aren't filtering
|
||||||
if ($params->get('cache', 1) == 1)
|
if ($params->get('cache', 1) == 1 && $searchId != '' && $searchWord != '')
|
||||||
{
|
{
|
||||||
// Fetch cache time from component parameters and convert to seconds
|
// Fetch cache time from component parameters and convert to seconds
|
||||||
$cacheTime = $params->get('cache_lifetime', 60);
|
$cacheTime = $params->get('cache_lifetime', 60);
|
||||||
@ -221,8 +223,17 @@ class PatchtesterModelPulls extends JModelList
|
|||||||
$search = $this->getState('filter.search');
|
$search = $this->getState('filter.search');
|
||||||
$searchId = $this->getState('filter.searchid');
|
$searchId = $this->getState('filter.searchid');
|
||||||
|
|
||||||
$pulls = $this->github->pulls->getList($this->getState('github_user'), $this->getState('github_repo'), 'open', $page);
|
// Check if we're searching for a single PR
|
||||||
usort($pulls, array($this, 'sortItems'));
|
if ($searchId != '' && $search == '')
|
||||||
|
{
|
||||||
|
$pulls = array();
|
||||||
|
$pulls[0] = $this->github->pulls->get($this->getState('github_user'), $this->getState('github_repo'), $searchId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$pulls = $this->github->pulls->getList($this->getState('github_user'), $this->getState('github_repo'), 'open', $page);
|
||||||
|
usort($pulls, array($this, 'sortItems'));
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($pulls as $i => &$pull)
|
foreach ($pulls as $i => &$pull)
|
||||||
{
|
{
|
||||||
@ -232,12 +243,6 @@ class PatchtesterModelPulls extends JModelList
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($searchId && $pull->number != $searchId)
|
|
||||||
{
|
|
||||||
unset($pulls[$i]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to find a Joomlacode issue number
|
// Try to find a Joomlacode issue number
|
||||||
$pulls[$i]->joomlacode_issue = 0;
|
$pulls[$i]->joomlacode_issue = 0;
|
||||||
|
|
||||||
@ -268,7 +273,7 @@ class PatchtesterModelPulls extends JModelList
|
|||||||
// If caching is enabled, save the request data
|
// If caching is enabled, save the request data
|
||||||
$params = $this->getState('params');
|
$params = $this->getState('params');
|
||||||
|
|
||||||
if ($params->get('cache') == 1)
|
if ($params->get('cache', 1) == 1 && $searchId != '' && $search != '')
|
||||||
{
|
{
|
||||||
$data = json_encode($pulls);
|
$data = json_encode($pulls);
|
||||||
file_put_contents(JPATH_CACHE . '/patchtester-page-' . $this->getPagination()->pagesCurrent . '.json', $data);
|
file_put_contents(JPATH_CACHE . '/patchtester-page-' . $this->getPagination()->pagesCurrent . '.json', $data);
|
||||||
|
Loading…
Reference in New Issue
Block a user