codex ticket rework
This commit is contained in:
@@ -18,9 +18,12 @@ class UpdateProjectTicket
|
||||
/**
|
||||
* @param array{
|
||||
* acceptance_criteria: string|null,
|
||||
* assignee_user_id: int|null,
|
||||
* author_user_id: int|null,
|
||||
* blocked_comment: string|null,
|
||||
* description: string|null,
|
||||
* is_blocked: bool,
|
||||
* story_points: int|null,
|
||||
* ticket_priority_id: int,
|
||||
* ticket_type_id: int,
|
||||
* parent_ticket_id: int|null,
|
||||
@@ -44,6 +47,8 @@ class UpdateProjectTicket
|
||||
}
|
||||
|
||||
$ticket->loadMissing([
|
||||
'assignee',
|
||||
'author',
|
||||
'fieldValues.ticketFieldDefinition',
|
||||
'fieldValues.userValue',
|
||||
'parentTicket',
|
||||
@@ -103,6 +108,14 @@ class UpdateProjectTicket
|
||||
$ticket->blocked_comment,
|
||||
$ticketAttributes['blocked_comment'],
|
||||
);
|
||||
$this->trackNumberChange(
|
||||
$changes,
|
||||
$summaryLabels,
|
||||
'story_points',
|
||||
'story points',
|
||||
$ticket->story_points,
|
||||
$ticketAttributes['story_points'],
|
||||
);
|
||||
|
||||
if ($ticket->ticket_type_id !== $ticketAttributes['ticket_type_id']) {
|
||||
$changes['ticket_type'] = [
|
||||
@@ -140,6 +153,26 @@ class UpdateProjectTicket
|
||||
$summaryLabels[] = 'parent ticket';
|
||||
}
|
||||
|
||||
if ($ticket->assignee_user_id !== $ticketAttributes['assignee_user_id']) {
|
||||
$changes['assignee'] = [
|
||||
'from' => $ticket->assignee?->name,
|
||||
'to' => $ticketAttributes['assignee_user_id'] === null
|
||||
? null
|
||||
: User::query()->find($ticketAttributes['assignee_user_id'])?->name,
|
||||
];
|
||||
$summaryLabels[] = 'assignee';
|
||||
}
|
||||
|
||||
if ($ticket->author_user_id !== $ticketAttributes['author_user_id']) {
|
||||
$changes['author'] = [
|
||||
'from' => $ticket->author?->name,
|
||||
'to' => $ticketAttributes['author_user_id'] === null
|
||||
? null
|
||||
: User::query()->find($ticketAttributes['author_user_id'])?->name,
|
||||
];
|
||||
$summaryLabels[] = 'author';
|
||||
}
|
||||
|
||||
$ticket->fill($ticketAttributes);
|
||||
|
||||
if ($ticket->isDirty()) {
|
||||
@@ -217,6 +250,29 @@ class UpdateProjectTicket
|
||||
$summaryLabels[] = $summaryLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $changes
|
||||
* @param array<int, string> $summaryLabels
|
||||
*/
|
||||
private function trackNumberChange(
|
||||
array &$changes,
|
||||
array &$summaryLabels,
|
||||
string $changeKey,
|
||||
string $summaryLabel,
|
||||
?int $currentValue,
|
||||
?int $newValue,
|
||||
): void {
|
||||
if ($currentValue === $newValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
$changes[$changeKey] = [
|
||||
'from' => $currentValue,
|
||||
'to' => $newValue,
|
||||
];
|
||||
$summaryLabels[] = $summaryLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $changes
|
||||
* @param array{value_user_id?: int|string|null} $fieldValueAttribute
|
||||
|
||||
Reference in New Issue
Block a user