Gitpro.Item (gitpro v1.0.0)

Copy Markdown View Source

One card on the board.

A project item is not an issue: it is a card that may point at an issue, at a pull request, or at nothing but its own title (a draft). All three are shown — a board with the drafts hidden is not the board anyone is looking at — and kind says which is which.

column is the card's position on the kanban board: the value of the board's single-select field, or nil for a card that has not been put in a column.

search is the row flattened into one lowercased string. It is built once, at decode time, because the search field filters on every keystroke and a few hundred cards is enough for the difference to be felt. The body is not in it: searching the text of every issue on a board finds a great many cards that merely mention the word, which is a different tool than this one.

Keys

The *_keys/1 functions are what Gitpro.Filter filters on, and each answers the key of a flag rather than the value itself. label_keys/1 and assignee_keys/1 answer [:none] for a card that has neither, so "unlabelled" and "unassigned" are flags you can turn off like any other rather than a state with no switch for it.

Summary

Functions

The assignee flags this card answers to, or [:none] when unassigned.

The key this card's column is filtered under.

Fills in search from everything else in the struct.

The label flags this card answers to, or [:none] when it has none.

Builds the lowercased string Gitpro.Filter matches a query against.

Which state flag this card answers to.

Every state a card can be in, in the order the filter lists them.

Types

kind()

@type kind() :: :issue | :pull_request | :draft

state()

@type state() :: :open | :closed | :merged | :none

state_key()

@type state_key() :: :open | :closed | :merged | :draft

t()

@type t() :: %Gitpro.Item{
  assignees: [String.t()],
  author: String.t() | nil,
  body: String.t() | nil,
  column: String.t() | nil,
  created_at: String.t() | nil,
  id: String.t(),
  kind: kind(),
  labels: [String.t()],
  milestone: String.t() | nil,
  number: pos_integer() | nil,
  repo: String.t() | nil,
  search: String.t(),
  state: state(),
  title: String.t(),
  updated_at: String.t() | nil,
  url: String.t() | nil
}

Functions

assignee_keys(item)

@spec assignee_keys(t()) :: [String.t() | :none]

The assignee flags this card answers to, or [:none] when unassigned.

column_key(item)

@spec column_key(t()) :: String.t() | :none

The key this card's column is filtered under.

Cards with no column share the :none bucket, which is a flag of its own so that "everything nobody has triaged yet" can be looked at on its own.

index(item)

@spec index(t()) :: t()

Fills in search from everything else in the struct.

label_keys(item)

@spec label_keys(t()) :: [String.t() | :none]

The label flags this card answers to, or [:none] when it has none.

searchable(item)

@spec searchable(t()) :: String.t()

Builds the lowercased string Gitpro.Filter matches a query against.

state_key(item)

@spec state_key(t()) :: state_key()

Which state flag this card answers to.

A merged pull request is its own state rather than a closed one: on a board that tracks pull requests, "closed" means the ones that were given up on, and lumping the merged in with them hides the difference that matters. A draft is its own state too — it has no state of its own to report.

state_keys()

@spec state_keys() :: [state_key()]

Every state a card can be in, in the order the filter lists them.