assignees

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package assignees is what both sheets' assignee pickers share: whom they offer to assign to an issue or a pull request, in what order, and how that offer is learned and searched with as few requests to GitHub as it takes.

A Finder offers people from the local People directory alone (Candidates), with no request: the user, the item's author and participants, the people assigned in the repository before, those who work on it, the rest of those GitHub listed as assignable there, and, while that list is cut short, the people who work on the owner's other repositories. It reads GitHub's whole list of a repository's assignable users at most weekly (Learn), one page of 100 for one point, and a search of it (Search) only when nothing the directory holds answers it: a whole list that named everyone answers every search, a search that named everyone it matched answers every longer search for a week, and any search answers the same words for ten minutes. One read runs at a time per repository and search, whichever sheet asks, so core builds one Finder for both.

The package knows no GitHub client and neither sheet: each sheet hands it the item (Item) and the read to make (Read), and core adapts the People directory to its Directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assignable

type Assignable struct {
	Login      string
	Name       string
	Listed     bool
	AssignedAt time.Time
}

Assignable is someone the directory knows can be assigned in a repository: whether GitHub listed them there (Listed), and when the app last saw them assigned there, zero for never.

type Candidate

type Candidate struct {
	Login string `json:"login"`
	Name  string `json:"name"`

	// Mine reports the signed-in user.
	Mine bool `json:"mine"`

	// Source is why the picker offers them.
	Source Source `json:"source"`

	// Reviewed, Authored, and Committed count the repository's pull requests they reviewed,
	// opened, and committed to, of those the app knows; for SourceOrg, of the repository
	// Where names.
	Reviewed  int `json:"reviewed"`
	Authored  int `json:"authored"`
	Committed int `json:"committed"`

	// AssignedAt is when the app last saw them assigned in the repository, and LastAt when it
	// last saw them work there, as RFC 3339, or "".
	AssignedAt string `json:"assignedAt"`
	LastAt     string `json:"lastAt"`

	// Where is the owner's other repository they were last seen working on, as
	// "owner/name", for SourceOrg; "" for any other.
	Where string `json:"where"`
}

Candidate is someone the picker offers to assign.

type Candidates

type Candidates struct {
	// People are those it offers, in the order of their Source, each once, never a bot, at
	// most 300, never nil.
	People []Candidate `json:"people"`

	// Total is how many people GitHub said can be assigned in the repository, as the last
	// read of its whole list counted them, and Complete reports that the read named every
	// one, so a search never asks GitHub. ReadAt is when that read was, as RFC 3339, or ""
	// before one was, and Stale whether one is due (Learn).
	Total    int    `json:"total"`
	Complete bool   `json:"complete"`
	ReadAt   string `json:"readAt"`
	Stale    bool   `json:"stale"`
}

Candidates is who the picker offers to assign to an issue or a pull request.

type Directory

type Directory interface {
	Known(ctx context.Context, name repo.Name) (Known, error)
	Covers(ctx context.Context, name repo.Name, query string) (bool, error)
	Keep(ctx context.Context, name repo.Name, query string, found Found) error
	MarkFailed(ctx context.Context, name repo.Name, query string) error
	Assigned(ctx context.Context, name repo.Name, logins []string) error
}

Directory is the People directory as the pickers use it: what it knows of a repository, whether what it holds answers a search (Covers), and the reads and assignments it keeps. core adapts *people.Service to it.

type Finder

type Finder struct {
	// contains filtered or unexported fields
}

Finder offers people to assign, and learns and searches who can be, for both sheets. A nil Finder offers no one, and reads nothing. It is safe for concurrent use.

func NewFinder

func NewFinder(dir Directory, logger *slog.Logger) *Finder

NewFinder returns a Finder over dir, logging to logger (nil discards).

func (*Finder) Candidates

func (f *Finder) Candidates(ctx context.Context, it Item) (Candidates, error)

Candidates returns whom the picker offers to assign to it, from the directory alone, with no request.

func (*Finder) Learn

func (f *Finder) Learn(ctx context.Context, it Item, read Read) (Candidates, error)

Learn reads GitHub's whole list of who can be assigned in its repository with read, when a read is due (Candidates.Stale), keeps it, and returns Candidates with what it learned: one request of one point, one at a time per repository. A read that fails is recorded, so none is due for 30 minutes, and is the error; one not due sends nothing.

func (*Finder) Search

func (f *Finder) Search(ctx context.Context, it Item, query string, read Read) (Candidates, error)

Search returns whom the picker offers to assign to it whose login or name matches query, those that match best first: from the directory alone when what it holds answers the search (Directory.Covers), else after one read of GitHub's assignable users that match, one point, which it keeps, the people it found and the list holds nothing else of marked SourceFound. One search per repository and words runs at a time. A read that fails is recorded, and is the error.

func (*Finder) Seen

func (f *Finder) Seen(ctx context.Context, name repo.Name, logins []string)

Seen keeps logins as assigned in the repository name, as a read saw them or the user just assigned them. A failure is logged.

type Found

type Found struct {
	People []Person
	Total  int
}

Found is what a read of a repository's assignable users found: the people it named, the first page, and how many GitHub said match in all.

type Item

type Item struct {
	Repo           repo.Name
	Viewer         string
	Author         string
	AuthorIsPerson bool
	Participants   []string
}

Item is the issue or pull request a picker is for, as its sheet read it: its repository, the signed-in user (Viewer), who opened it and whether that is a person, and who took part in it, people only.

type Known

type Known struct {
	Assignable []Assignable
	WorksHere  []Worker
	Org        []Worker
	Total      int
	Complete   bool
	ReadAt     time.Time
	Stale      bool
}

Known is what the directory knows of who can be assigned in a repository: everyone it learned can be (Assignable, by login), who works on it (WorksHere, the highest ranked first), and who works on the owner's other repositories (Org, likewise); and of GitHub's whole list, how many it said can be (Total), whether its last read named everyone (Complete), when that read was (ReadAt, zero before one), and whether one is due (Stale).

type Person

type Person struct {
	Login string
	Name  string
}

Person is someone a read of GitHub named: their login, and their profile's display name, "" when it gave none.

type Read

type Read func(ctx context.Context, query string) (Found, error)

Read reads the assignable users of the item's repository whose login or name matches query, "" for everyone, as the sheet that asks makes the read: one GraphQL request of one point, through its inbox's footing.

type Source

type Source string

Source is why the picker offers someone, which names the section they are listed in.

const (
	// SourceYou is the signed-in user.
	SourceYou Source = "you"

	// SourceAuthor opened the issue or the pull request.
	SourceAuthor Source = "author"

	// SourceParticipant took part in it: commented, or reviewed a pull request.
	SourceParticipant Source = "participant"

	// SourceAssignedBefore was seen assigned in the repository before.
	SourceAssignedBefore Source = "assigned_before"

	// SourceWorksHere works on the repository, as the People directory knows it.
	SourceWorksHere Source = "works_here"

	// SourceListed is one GitHub listed as assignable in the repository.
	SourceListed Source = "listed"

	// SourceOrg works on another of the owner's repositories.
	SourceOrg Source = "org"

	// SourceFound is one a search of GitHub just found, whom the app knew nothing else of.
	SourceFound Source = "found"
)

The sources, in the order a list offers them.

type Worker

type Worker struct {
	Login     string
	Name      string
	Reviewed  int
	Authored  int
	Committed int
	LastAt    time.Time
	Where     string
}

Worker is someone the directory knows works on a repository: what they did there and when they were last seen there, and, among the owner's other repositories, which one (Where).

Directories

Path Synopsis
Package assigneestest is the shared fake of internal/assignees for the sheets' tests: a Directory in memory.
Package assigneestest is the shared fake of internal/assignees for the sheets' tests: a Directory in memory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL