* url parameter options added
This commit is contained in:
parent
336fd6acc5
commit
c40e39c4ad
@ -27,5 +27,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$app->get('/', App\Action\HomePageAction::class, 'home');
|
$app->get('/', App\Action\HomePageAction::class, 'home');
|
||||||
|
$app->get('/{jiraQueryName}[/{filterId:\d+}]', App\Action\HomePageAction::class, 'home.params');
|
||||||
$app->get('/api/ping', App\Action\PingAction::class, 'api.ping');
|
$app->get('/api/ping', App\Action\PingAction::class, 'api.ping');
|
||||||
$app->get('/api/dbg', App\Action\DbgAction::class, 'api.dbg');
|
$app->get('/api/dbg', App\Action\DbgAction::class, 'api.dbg');
|
||||||
|
|||||||
@ -23,8 +23,10 @@ class HomePageAction implements ServerMiddlewareInterface
|
|||||||
|
|
||||||
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
|
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
|
||||||
{
|
{
|
||||||
|
$queryName = $request->getAttribute('jiraQueryName', 'default');
|
||||||
|
$filterId = $request->getAttribute('filterId');
|
||||||
$data = [
|
$data = [
|
||||||
'chartRows' => $this->jiraService->getChartData(),
|
'chartRows' => $this->jiraService->getChartData($queryName, $filterId),
|
||||||
];
|
];
|
||||||
|
|
||||||
return new HtmlResponse($this->template->render('app::home-page', $data));
|
return new HtmlResponse($this->template->render('app::home-page', $data));
|
||||||
|
|||||||
@ -33,9 +33,9 @@ class JiraCollectorService
|
|||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getChartData()
|
public function getChartData(string $queryName, $filterId)
|
||||||
{
|
{
|
||||||
$supportTickets = $this->getSupportJiraTickets();
|
$supportTickets = $this->getSupportJiraTickets($queryName, $filterId);
|
||||||
$openTickets = array_values(array_filter($supportTickets, function(JiraIssue $ticket){
|
$openTickets = array_values(array_filter($supportTickets, function(JiraIssue $ticket){
|
||||||
return $ticket->getResolvedAt() === null;
|
return $ticket->getResolvedAt() === null;
|
||||||
}));
|
}));
|
||||||
@ -63,16 +63,18 @@ class JiraCollectorService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param string $queryName
|
||||||
|
* @param $filterId
|
||||||
* @return array|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public function getSupportJiraTickets(): ?array
|
public function getSupportJiraTickets(string $queryName, $filterId): ?array
|
||||||
{
|
{
|
||||||
$user = $this->config->get('jira.user');
|
$user = $this->config->get('jira.user');
|
||||||
$password = $this->config->get('jira.password');
|
$password = $this->config->get('jira.password');
|
||||||
$jiraResultUrl = $this->config->get('jira.query');
|
$jiraResultUrl = $this->config->get(sprintf('jira.query.%s', $queryName));
|
||||||
|
|
||||||
$response = $this->httpClient
|
$response = $this->httpClient
|
||||||
->setUri($jiraResultUrl)
|
->setUri($filterId ? sprintf($jiraResultUrl, $filterId) : $jiraResultUrl)
|
||||||
->setAuth($user, $password)
|
->setAuth($user, $password)
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user