[GitHub] Allow custom search query (#2593)

This commit is contained in:
Yaman Qalieh 2022-04-03 04:07:35 -04:00 committed by GitHub
parent d123e6007e
commit 7dcf09a876
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -4,7 +4,7 @@ class GithubIssueBridge extends BridgeAbstract {
const MAINTAINER = 'Pierre Mazière'; const MAINTAINER = 'Pierre Mazière';
const NAME = 'Github Issue'; const NAME = 'Github Issue';
const URI = 'https://github.com/'; const URI = 'https://github.com/';
const CACHE_TIMEOUT = 600; // 10min const CACHE_TIMEOUT = 0; // 10min
const DESCRIPTION = 'Returns the issues or comments of an issue of a github project'; const DESCRIPTION = 'Returns the issues or comments of an issue of a github project';
const PARAMETERS = array( const PARAMETERS = array(
@ -24,6 +24,11 @@ class GithubIssueBridge extends BridgeAbstract {
'c' => array( 'c' => array(
'name' => 'Show Issues Comments', 'name' => 'Show Issues Comments',
'type' => 'checkbox' 'type' => 'checkbox'
),
'q' => array(
'name' => 'Search Query',
'defaultValue' => 'is:issue is:open sort:updated-desc',
'required' => true
) )
), ),
'Issue comments' => array( 'Issue comments' => array(
@ -40,7 +45,6 @@ class GithubIssueBridge extends BridgeAbstract {
const BRIDGE_OPTIONS = array(0 => 'Project Issues', 1 => 'Issue comments'); const BRIDGE_OPTIONS = array(0 => 'Project Issues', 1 => 'Issue comments');
const URL_PATH = 'issues'; const URL_PATH = 'issues';
const SEARCH_QUERY_PATH = 'issues'; const SEARCH_QUERY_PATH = 'issues';
const SEARCH_QUERY = '?q=is%3Aissue+sort%3Aupdated-desc';
public function getName(){ public function getName(){
$name = $this->getInput('u') . '/' . $this->getInput('p'); $name = $this->getInput('u') . '/' . $this->getInput('p');
@ -67,7 +71,7 @@ class GithubIssueBridge extends BridgeAbstract {
if($this->queriedContext === static::BRIDGE_OPTIONS[1]) { if($this->queriedContext === static::BRIDGE_OPTIONS[1]) {
$uri .= static::URL_PATH . '/' . $this->getInput('i'); $uri .= static::URL_PATH . '/' . $this->getInput('i');
} else { } else {
$uri .= static::SEARCH_QUERY_PATH . static::SEARCH_QUERY; $uri .= static::SEARCH_QUERY_PATH . '?q=' . urlencode($this->getInput('q'));
} }
return $uri; return $uri;
} }

View File

@ -22,6 +22,11 @@ class GitHubPullRequestBridge extends GithubIssueBridge {
'c' => array( 'c' => array(
'name' => 'Show Pull Request Comments', 'name' => 'Show Pull Request Comments',
'type' => 'checkbox' 'type' => 'checkbox'
),
'q' => array(
'name' => 'Search Query',
'defaultValue' => 'is:pr is:open sort:created-desc',
'required' => true
) )
), ),
'Pull Request comments' => array( 'Pull Request comments' => array(
@ -37,5 +42,4 @@ class GitHubPullRequestBridge extends GithubIssueBridge {
const BRIDGE_OPTIONS = array(0 => 'Project Pull Requests', 1 => 'Pull Request comments'); const BRIDGE_OPTIONS = array(0 => 'Project Pull Requests', 1 => 'Pull Request comments');
const URL_PATH = 'pull'; const URL_PATH = 'pull';
const SEARCH_QUERY_PATH = 'pulls'; const SEARCH_QUERY_PATH = 'pulls';
const SEARCH_QUERY = '?q=is%3Apr+sort%3Acreated-desc';
} }