Skip to content

Commit

Permalink
no-task Add functionality to generate sprint goals based on a list of…
Browse files Browse the repository at this point in the history
… tickets.
  • Loading branch information
nxsschoenfeld committed Jul 20, 2023
1 parent 16d0d9b commit 44d671e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
19 changes: 19 additions & 0 deletions aiticketsprintgoals
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/php
<?php

if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require __DIR__ . '/vendor/autoload.php';
} else {
require_once(__DIR__ . '/../../autoload.php');
}

$listOfTickets = $_SERVER['argv'][1] ?? null;
if ($listOfTickets === null) {
echo "Please enter a valid list of tickets. \nExample:\n> aiticketsprintgoals \"SPRY-1234,SPRY-1000,SPRY-2000\"";
exit(0);
}

$overwritePrompt = $_SERVER['argv'][2] ?? null;

$sprintGoals = new \AiJira\SprintGoals\SprintGoals();
echo $sprintGoals->generateSprintGoalsByTicket($listOfTickets, $overwritePrompt);
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"aiticketinterview",
"aiticketvalidator",
"aiticketscorer",
"aitickettestcases"
"aitickettestcases",
"aiticketsprintgoals"
],
"authors": [
{
Expand Down
22 changes: 22 additions & 0 deletions src/AiJira/Jira/JiraClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ public function getTicketsBySprintName(string $sprintName): array
return $this->postApi($endpoint, $data);
}

public function getTicketsByTicketList(string $ticketList): array
{
$endpoint = sprintf(
'%s%s',
getenv('AI_JIRA_URL'),
self::JIRA_SEARCH_ENDPOINT
);

$data = [
'jql' => sprintf('project = "%s" and key IN (%s) and type not in (Epic) order by created DESC', getenv('AI_JIRA_PROJECT'), $ticketList),
'fields' => [
'summary',
'description',
'labels',
'issuetype',
'timetracking'
],
];

return $this->postApi($endpoint, $data);
}

public function getTasksBySprintName(string $sprintName): array
{
$endpoint = sprintf(
Expand Down
13 changes: 13 additions & 0 deletions src/AiJira/SprintGoals/SprintGoals.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,17 @@ public function generateSprintGoals(string $sprintName, ?string $overwritePrompt
return $this->openaiClient->getGeneratedSprintGoals($tasks, $labels, null) . "\n\nOverall:\n" . $this->openaiClient->getGeneratedSprintGoals($stories, [], null);
}
}

public function generateSprintGoalsByTicket(string $ticket, ?string $overwritePrompt): string
{
$ticketData = $this->jiraClient->getTicketsByTicketList($ticket);
[$tasks, $stories] = $this->mapper->splitTicketsByType($ticketData);
$labels = $this->jiraFormatter->extractLabels($tasks);

if ($overwritePrompt) {
return $this->openaiClient->getGeneratedSprintGoals([$tasks, $stories], [], $overwritePrompt);
} else {
return $this->openaiClient->getGeneratedSprintGoals($tasks, $labels, null) . "\n\nOverall:\n" . $this->openaiClient->getGeneratedSprintGoals($stories, [], null);
}
}
}

0 comments on commit 44d671e

Please sign in to comment.