Documentation
¶
Overview ¶
Package inboxqueue builds the app's Inbox from the daemon's own state: the open pull requests with what each waits for, which saved inboxes hold each, and how many wait on the person.
The total (Count) is the shared definition of the number on the sidebar's Inbox heading and the desktop app's dock badge and tray: the distinct unsnoozed actionable pull requests in the queue, each once however many clones hold it. It ignores saved inboxes, their badge switches and any filter. Which inboxes hold a pull request is decided here too, with the inbox filter language of internal/prfilter, so the app does not match every inbox query against every pull request itself.
Index ¶
- Constants
- func Count(entries []reviewindex.Entry, queue []jobs.Job, groups []reviewgroups.Group, ...) int
- func Folded(inbox inboxes.Inbox) string
- func Key(pr reviewindex.Entry) string
- func Matching(items []Item, query string) []string
- type Draft
- type Inbox
- type Item
- type Queue
- type Service
- type Snoozes
Constants ¶
const ( Review = "review" Clone = "clone" Fix = "fix" Merge = "merge" Update = "update" Other = "other" Waiting = "" )
Kinds of Item: what the person does next about a pull request in the queue, as the app's UpNextKind, then Other for someone else's that waits on nothing from them and Waiting for their own that waits on others.
Variables ¶
This section is empty.
Functions ¶
func Count ¶
func Count(entries []reviewindex.Entry, queue []jobs.Job, groups []reviewgroups.Group, snoozes Snoozes, now time.Time) int
Count is the number of pull requests in the Inbox: each open one asking for the user's review or assigned to them, and each of their own with something for them to do (fix, merge or update), less those snoozed at now or archived. Saved inboxes play no part.
func Folded ¶
Folded is the inbox's query with its older parts (what, owners, risk, repositories, bots) folded in, as the app matches it. An unknown what or risk reads as "any", as the app reads it.
func Key ¶
func Key(pr reviewindex.Entry) string
Key names a pull request across the clones that hold it, as the app's upNextKey does.
Types ¶
type Draft ¶
type Draft struct {
Query string `json:"query"`
Problem string `json:"problem"`
Matches []string `json:"matches"`
}
Draft is what a query not saved yet would hold: the keys of the items it matches, or why it cannot be read (Problem), in which case it holds them all as a filter that does not read narrows nothing.
type Inbox ¶
Inbox is a saved inbox as matched: the query its parts fold into, and how many listed items it holds.
type Item ¶
type Item struct {
Key string `json:"key"`
// Kind is what it waits for, as an inbox's waiting= filter reads it: a
// queue kind, Other, or Waiting (""). One an agent is fixing now is Fix,
// with Fixing set, though it is not in the queue.
Kind string `json:"kind"`
Fixing bool `json:"fixing,omitempty"`
// Snoozed is set while the person's snooze hides it.
Snoozed bool `json:"snoozed,omitempty"`
// Archived is set once the person archived it: it never shows in an
// inbox again.
Archived bool `json:"archived,omitempty"`
// Inboxes are the ids of the saved inboxes that hold it, in their order.
Inboxes []string `json:"inboxes"`
// contains filtered or unexported fields
}
Item is an open pull request as the inboxes match it: one per Key, the clone that speaks for it chosen as the app chooses.
func Items ¶
func Items(entries []reviewindex.Entry, queue []jobs.Job, groups []reviewgroups.Group, snoozes Snoozes, now time.Time) []Item
Items classifies the open pull requests of entries (the index's, in its order), one per Key, with queue the job queue's and groups the review groups, and marks those snoozed at now and those archived. Their Inboxes are empty.
func (Item) Hidden ¶
Hidden reports whether the person's snooze or archive keeps the item out of every inbox.
type Queue ¶
type Queue struct {
Count int `json:"count"`
Items []Item `json:"items"`
Inboxes []Inbox `json:"inboxes"`
}
Queue is the Inbox: every open pull request with what it waits for and the inboxes that hold it, the total waiting on the person (Count) and each inbox's own count. Inboxes is nil when the saved inboxes could not be read.
type Service ¶
type Service struct {
Index func(context.Context) (reviewindex.Snapshot, error)
// Jobs reads the jobs the Queue looks at, which are only the queued or
// running fixes (jobs.Queue.ActiveFixes), not the history.
Jobs func() []jobs.Job
Groups func(context.Context) ([]reviewgroups.Group, error)
Snoozes func() (json.RawMessage, error)
// Inboxes reads the saved inboxes. When it is nil or fails, no inbox
// holds anything and the Queue's Inboxes is nil.
Inboxes func() ([]inboxes.Inbox, error)
Now func() time.Time
}
Service builds the Queue from the daemon's own index, job queue, groups, saved ui-state and saved inboxes, read on each request.
func (*Service) CountHandler ¶
CountHandler answers GET /api/index?view=waiting with {"waiting":N}, the Inbox count, which the desktop app polls for its badge and tray; every other request goes to index. The host applies its launch authentication first.
type Snoozes ¶
type Snoozes struct {
Snoozed map[string]int64 `json:"snoozed"`
Held map[string]string `json:"held"`
Archived map[string]int64 `json:"archived"`
}
Snoozes is what the app saved as ui-state "inbox" that hides a pull request from the queue: until a time (Unix milliseconds) or while its head stays the one it was held on, or for good once archived (when, in Unix milliseconds). All are keyed by Key.
func ParseSnoozes ¶
func ParseSnoozes(raw json.RawMessage) (Snoozes, error)
ParseSnoozes reads the ui-state "inbox" value; null, as before the app saved one, hides nothing.