Skip to content

Navigation Menu

Sign in
Sign up

DT-157: Task manager — types & pure logic (WorkItem, Ticket, key/status/person functions) - #168

Merged
kigiri merged 2 commits into
master from
157-task-manager-types-pure-logic-workitem-ticket-keystatusperson-functions
Aug 17, 2026
Merged

DT-157: Task manager — types & pure logic (WorkItem, Ticket, key/status/person functions) #168
kigiri merged 2 commits into
master from
157-task-manager-types-pure-logic-workitem-ticket-keystatusperson-functions

Conversation

@abdotop

@abdotop abdotop commented Jul 27, 2026

Copy link
Copy Markdown
Member

Implement pure logic and types for task manager ticket aggregation

@abdotop abdotop self-assigned this Jul 27, 2026
@abdotop abdotop changed the title (削除) DT-157:Task manager — types & pure logic (WorkItem, Ticket, key/status/person functions) (削除ここまで) (追記) DT-157: Task manager — types & pure logic (WorkItem, Ticket, key/status/person functions) (追記ここまで) Jul 27, 2026
Comment thread api/tickets.ts
export const normalizeKey = (rawKey: string): string | undefined => {
const normalized = rawKey.toUpperCase().replace(/[^A-Z0-9]/g, '')
return KEY_SHAPE.test(normalized) ? normalized : undefined
}

@kigiri kigiri Jul 31, 2026
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TNT-879-do-something would fail
/^([A-Z]+)[^0-9]?([0-9]+)/ would normalize all

[_, prefix, id] = 'TNT545-hey'.split(/^([A-Z]+)[^0-9]?([0-9]+)/)
if (!id) return undefined
`${prefix}${id}`

Comment thread api/tickets.ts Outdated
return withoutKeyPrefix || github.title
}

return items[0].title

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we could have a more generic "if this title has the project prefix clean it up" and not even care about the specific source

Comment thread api/tickets.ts Outdated
): Ticket[] => {
const groups = Map.groupBy(
items,
(item) => extractKey(item) ?? `${item.source}:${item.externalId}`,

@kigiri kigiri Jul 31, 2026
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`extractKey(item) || `${item.source}:${item.externalId}`

we don't want to accept falsy values as valid keys

Comment thread api/tickets.ts Outdated
(ref.email != null && person.emails.includes(ref.email)) ||
(ref.discordId != null && person.discordId === ref.discordId) ||
(ref.jiraAccountId != null && person.jiraAccountId === ref.jiraAccountId)
)

@kigiri kigiri Jul 31, 2026
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export const resolvePerson = (ref: PersonRef, person: Person) =>
 (ref.login != null && person.githubLogin === ref.login) ||
 (ref.email != null && person.emails.includes(ref.email)) ||
 (ref.discordId != null && person.discordId === ref.discordId) ||
 (ref.jiraAccountId != null && person.jiraAccountId === ref.jiraAccountId)
 )
function resolvePersonMethod(person: Person) {
 return resolvePerson(person, this)
}
directory.find(resolvePersonMethod, ref)

Comment thread api/tickets.ts Outdated
const resolveUnique = (directory: Person[], refs: PersonRef[]): Person[] => {
const resolved = refs
.map((ref) => resolvePerson(directory, ref))
.filter((person): person is Person => person != null)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const persons = new Set<Person>()
for (const ref of refs) {
 const match = directory.find(resolvePerson, ref)
 match && persons.add(match)
}
return [...persons]
// if match ref is not stable:
const persons = new Map<string, Person>()
for (const ref of refs) {
 const match = directory.find(resolvePerson, ref)
 match && persons.set(match.id, match)
}
return [...persons.values()]

Comment thread api/tickets.ts Outdated
reviewers: resolveUnique(
directory,
groupItems.flatMap((item) => item.reviewerRefs ?? []),
),

@kigiri kigiri Jul 31, 2026
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolveUnique(directory, groupItems, 'reviewerRefs')
// later
const persons = new Set<Person>()
for (const item of items) {
 if (!item[personKey]) continue
 for (const ref of item[personKey]) {
 const match = directory.find(resolvePerson, ref)
 match && persons.add(match)
 }
}
return [...persons]

kigiri merged commit 02496ca into master Aug 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kigiri kigiri kigiri left review comments

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Task manager — types & pure logic (WorkItem, Ticket, key/status/person functions)

2 participants

AltStyle によって変換されたページ (->オリジナル) /