Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GitHub] Allow custom search query #2593

Merged
merged 1 commit into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions bridges/GithubIssueBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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');
Expand All @@ -67,7 +71,7 @@ public function getURI() {
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;
}
Expand Down
6 changes: 5 additions & 1 deletion bridges/GithubPullRequestBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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';
}