From 7dcf09a876eff6a3d5af79b4329b6e47728f608e Mon Sep 17 00:00:00 2001 From: Yaman Qalieh Date: Sun, 3 Apr 2022 04:07:35 -0400 Subject: [PATCH] [GitHub] Allow custom search query (#2593) --- bridges/GithubIssueBridge.php | 10 +++++++--- bridges/GithubPullRequestBridge.php | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/bridges/GithubIssueBridge.php b/bridges/GithubIssueBridge.php index 5834f72a..9c82e4e6 100644 --- a/bridges/GithubIssueBridge.php +++ b/bridges/GithubIssueBridge.php @@ -4,7 +4,7 @@ class GithubIssueBridge extends BridgeAbstract { const MAINTAINER = 'Pierre Mazière'; const NAME = 'Github Issue'; 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 PARAMETERS = array( @@ -24,6 +24,11 @@ class GithubIssueBridge extends BridgeAbstract { 'c' => array( 'name' => 'Show Issues Comments', 'type' => 'checkbox' + ), + 'q' => array( + 'name' => 'Search Query', + 'defaultValue' => 'is:issue is:open sort:updated-desc', + 'required' => true ) ), 'Issue comments' => array( @@ -40,7 +45,6 @@ class GithubIssueBridge extends BridgeAbstract { const BRIDGE_OPTIONS = array(0 => 'Project Issues', 1 => 'Issue comments'); const URL_PATH = 'issues'; const SEARCH_QUERY_PATH = 'issues'; - const SEARCH_QUERY = '?q=is%3Aissue+sort%3Aupdated-desc'; public function getName(){ $name = $this->getInput('u') . '/' . $this->getInput('p'); @@ -67,7 +71,7 @@ class GithubIssueBridge extends BridgeAbstract { if($this->queriedContext === static::BRIDGE_OPTIONS[1]) { $uri .= static::URL_PATH . '/' . $this->getInput('i'); } else { - $uri .= static::SEARCH_QUERY_PATH . static::SEARCH_QUERY; + $uri .= static::SEARCH_QUERY_PATH . '?q=' . urlencode($this->getInput('q')); } return $uri; } diff --git a/bridges/GithubPullRequestBridge.php b/bridges/GithubPullRequestBridge.php index cb70d7fc..46d819af 100644 --- a/bridges/GithubPullRequestBridge.php +++ b/bridges/GithubPullRequestBridge.php @@ -22,6 +22,11 @@ class GitHubPullRequestBridge extends GithubIssueBridge { 'c' => array( 'name' => 'Show Pull Request Comments', 'type' => 'checkbox' + ), + 'q' => array( + 'name' => 'Search Query', + 'defaultValue' => 'is:pr is:open sort:created-desc', + 'required' => true ) ), '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 URL_PATH = 'pull'; const SEARCH_QUERY_PATH = 'pulls'; - const SEARCH_QUERY = '?q=is%3Apr+sort%3Acreated-desc'; }