Documentation
¶
Overview ¶
Package task holds the tasks and their pure rules.
Index ¶
- Constants
- Variables
- func ActiveSince(f UnitFacts, e Task) bool
- func AddWorkdays(t time.Time, n int, loc *time.Location) time.Time
- func ParseDeadline(s string, loc *time.Location) (time.Time, bool)
- func ProjectsOf(all []Task) map[ID]ProjectStatus
- func UnitOf(id ID) unit.Unit
- func VerbEventKind(v Verb) string
- func VerbEventKinds(verbs []string) []string
- type Actor
- type Category
- type Change
- type ChangeOp
- type Codec
- type Counters
- type ID
- type ItemRef
- type Me
- type Profile
- type ProjectStatus
- type PropType
- type Props
- type Query
- type ReviewRun
- type Role
- type State
- type States
- type Task
- func (e *Task) Become(s State, st States)
- func (e Task) CapturedByUser() bool
- func (e Task) FirstUnit() (unit.Unit, bool)
- func (e Task) IsProject() bool
- func (e *Task) MoveTo(c Category, st States) error
- func (e Task) Open() bool
- func (e Task) Prop(name string) Value
- func (e Task) ReviewDue(now time.Time) bool
- func (e Task) ReviewInterval() time.Duration
- func (e Task) Role(p Profile, r Role) Value
- func (e Task) Same(o Task) bool
- func (e *Task) SetProp(name string, v Value, by Writer, at time.Time)
- func (e *Task) SetRole(p Profile, r Role, v Value, by Writer, at time.Time)
- func (e Task) Snoozed() bool
- type UnitFacts
- type Value
- type Verb
- type View
- type Writer
- type Written
Constants ¶
const ( OverTasks = "tasks" OverGates = "gates" )
What a view lists: the stored tasks, or the gates.
const ( PropKind = "kind" // PropOwner is who owns the task; the waiting verb's on names it. PropOwner = "owner" // PropCheckOn is when to check on a task someone else owes; the waiting verb's resurface sets it. PropCheckOn = "check_on" // PropLastNudge is when a nudge last went to whoever owes the task; the task.nudged effect writes it. PropLastNudge = "last_nudge" // PropUnfollowed is when reconcile dropped a unit's own task because nobody followed the unit any more, so // following it again brings the task back; a person's drop never sets it. PropUnfollowed = "unfollowed" )
The properties the loop's own rules read, as the bundled tasks.toml declares them.
const ( OriginDerived = "derived" OriginUser = "user" OriginMessage = "message" OriginDraft = "draft" OriginGate = "gate" )
const DefaultReviewEvery = 7 * 24 * time.Hour
DefaultReviewEvery is the review interval of a project that sets none.
const KindProject = "project"
KindProject is the value of the kind property the project verb gives the parent it creates, and the one it attaches tasks to.
Variables ¶
var Actors = []Actor{ActorPerson, ActorWorkflow, ActorAgent, ActorPlugin}
Actors are every actor.
var Categories = []Category{CategoryInbox, CategoryReady, CategoryActive, CategoryWaiting, CategoryDeferred, CategoryDone, CategoryDropped}
Categories are every category, in the order a task moves through them.
var ErrNoStateOf = errors.New("the profile declares no state of the category")
ErrNoStateOf is a move into a category the profile declares no state of.
var PropTypes = []PropType{PropString, PropStrings, PropInt, PropEnum, PropDate, PropDuration, PropActor, PropActors}
PropTypes are every property type.
var RoleTypes = map[Role]PropType{RoleArea: PropString, RoleContexts: PropStrings, RoleStar: PropEnum, RoleDeadline: PropDate, RolePromise: PropDate}
RoleTypes are the type of the property each role acts on.
var Roles = []Role{RoleArea, RoleContexts, RoleStar, RoleDeadline, RolePromise}
Roles are every role.
var Writers = []Writer{WriterPerson, WriterWorkflow, WriterAgent, WriterPlugin}
Writers are every writer.
Functions ¶
func ActiveSince ¶
ActiveSince says whether a person's activity on f.Unit came after the user saw task e, or after e was made when they never did.
func AddWorkdays ¶
AddWorkdays is t moved n working days (Monday to Friday) forward, at the same clock time in loc.
func ParseDeadline ¶
ParseDeadline reads an item's deadline: RFC 3339 as is, "YYYY-MM-DD" as 18:00 that day in loc, anything else none.
func ProjectsOf ¶
func ProjectsOf(all []Task) map[ID]ProjectStatus
ProjectsOf is the status of each project in all over the actions in all.
func VerbEventKind ¶
VerbEventKind is the kind of the event running v on a task records.
func VerbEventKinds ¶
VerbEventKinds are the kinds of the events of verbs, the profile's.
Types ¶
type Actor ¶
type Actor string
Actor is who ran a transition or resolved a gate; the same set as Writer.
type Category ¶
type Category string
Category is the closed set a profile's state belongs to; Go reads a task's category, never its state's name.
type Change ¶
func Activity ¶
Activity marks Changed the deferred and waiting tasks of f.Unit when f.LastHuman is after what the user saw (SeenAt, or Created before any). It moves no task: a task never returns to the inbox on activity, and a wake on activity is the wakes' to match.
func Reconcile ¶
func Reconcile(f UnitFacts, its []items.Item, me Me, have []Task, st Profile, now time.Time) ([]Change, error)
Reconcile is what the items of one unit call for, given the tasks that hold them or the unit.
One task per task key (items.Item.TaskKey, else the item id) of the open items that wait on Me, or that Me requested or f.Cares about and wait on others. An item a task already holds stays with that task, so a task the user merged keeps its items, and every item of a key goes to the task holding one of them. A key no task holds that names f.Unit goes to the unit's own task (UnitTask) while it is open, else to the oldest open task holding f.Unit as a link, such as a task you started whose pull request was attached, else to its own closed one; any other gets a new task, DerivedID of the key, in the first state of the category its first item proposes (items.Item.Initial), else the inbox for an item waiting on Me and the waiting category for one waiting on others. A new task takes the item's contexts and deadline in the properties of RoleContexts and RoleDeadline, and the kind f.Kind names, as the plugin writes them.
A derived task none of whose items calls for it any more is resolved into the done category, except the task of a key that names f.Unit: the unit's one task lives as long as its unit, so it ends through the profile, and is dropped once its card says the user no longer Cares about the unit (PropUnfollowed), to come back when they do again. An item of that key that waits on nobody keeps the task while f Cares. A task that was clarified never returns to the inbox: an item that opens again on a done task moves it back into the ready category with Changed set, and an open task keeps its state. A task the user dropped stays dropped.
Never changes the state, the parent or a property the user set, except to resolve and to reopen as said.
Due: items.Item.Deadline in RFC 3339 is taken as is; "YYYY-MM-DD" is 18:00 in now's location that day; anything else is none.
type Codec ¶
type Codec struct{}
Codec is the codec of the task provider: a unit's key is a task's ID.
func (Codec) Provider ¶
func (Codec) Provider() unit.ProviderID
type Counters ¶
type Counters struct {
Area string
Views map[View]int // every view that lists something, narrowed to Area
Areas map[string]int // the open tasks per area
Contexts map[string]int // the open tasks per context, within Area
Badge int // the sum of the views the profile's badge names
}
Counters are the counts of the profile's views over Area ("" every area).
type ID ¶
type ID string
ID is "t-" + 16 hex. A task an item calls for: DerivedID, so a re-derivation is idempotent; captures and projects: random. Draft tasks: "draft:<draft id>".
func DerivedID ¶
DerivedID is the id of the task item of u calls for, so a re-derivation finds it again. It hashes as the action entries of schema version 6 did, so the tasks they became keep matching their items.
type Profile ¶
Profile is the profile as the rules read it: its states, and the property each role acts on with its values, "" for a role no property takes.
type ProjectStatus ¶
type Query ¶
Query selects a view's tasks, narrowed to the tasks whose area is Area and that hold every one of Contexts. A store reads All only: every task when true, else the open ones (neither done nor dropped).
type ReviewRun ¶
type ReviewRun struct {
ID string
StartedAt time.Time
FinishedAt time.Time // zero while a step is open
Done []string
}
ReviewRun is one review: when it started, the steps done (the views they walk), and when the last of them was.
type Role ¶
type Role string
Role is a mechanism of the loop that reads or writes a task property: the profile's tasks.toml gives it to the property it acts on, so Go names the role and never the property.
const ( // RoleArea is the property the area filter of the lists and their counters reads, which the area handler // sets and a new parent takes from the task it starts with: a string. RoleArea Role = "area" // RoleContexts is the property the contexts filter reads, which the context handler sets and a task takes // from the item or the request that opens it: a string[]. RoleContexts Role = "contexts" // RoleStar is the property the star handler toggles between its first value, starred, and its second: an // enum. RoleStar Role = "star" // RoleDeadline is the property a task takes from its items' deadline, and a draft's task from its gate's // window: a date. RoleDeadline Role = "deadline" // RolePromise is the property the promise handler sets from the time you promise an answer by, which the // fact task.promised reads: a date. RolePromise Role = "promise" )
The roles, a closed set.
type State ¶
type State string
State is a state the profile declares (tasks.toml); Go reads its Category, never its name.
type States ¶
States are the profile's states as the rules read them: the category of a state, and the first state of a category, which a task moved into that category takes.
type Task ¶
type Task struct {
ID ID
// State is the task's state; Category is its category, which every rule reads.
State State
Category Category
Title string
Notes string
Items []ItemRef
// Resolved are the items the task held that no longer call for it, such as one resolved: they keep the
// task as their holder, so an item that opens again comes back to it.
Resolved []ItemRef
Units []unit.Unit // attached units; their cards render in the detail
// Props are the task's properties; Written says who wrote each, and when.
Props Props
Written map[string]Written
Parent ID // "" none
Position int // order among its parent's children
Sequential bool
// Asleep says the task holds a wake (wake.Wake), as the store reads it; writing a task leaves its wake as
// it is.
Asleep bool
Changed bool // "changed since you saw it"; cleared by the seen verb
SeenAt time.Time
Origin string // "derived", "user", "message", "draft"
Created, Updated time.Time
// A parent's review interval (zero: DefaultReviewEvery) and last review.
ReviewEvery time.Duration
ReviewedAt time.Time
}
func Place ¶
Place puts e among its project's other actions at position pos (1 first; past the end, last) and numbers them all from 1 in that order.
func UnitTask ¶
UnitTask is u's own task among ts, whatever its state: of the tasks whose first unit is u, an open one first, the one holding an item of u, then the oldest, then by id; with none open, the one updated last.
func (*Task) Become ¶
Become moves the task to state s, in the category st declares of it; an undeclared state keeps the task's category.
func (Task) CapturedByUser ¶
CapturedByUser says whether the user made the task, rather than the loop deriving it from a source's items or opening it for a gate.
func (Task) FirstUnit ¶
FirstUnit is the unit the task is about: its first unit, else its first item's.
func (*Task) MoveTo ¶
MoveTo moves the task into category c, in the first state st declares of it; ErrNoStateOf, naming c, when st declares none, and the task is left as it was.
func (Task) Open ¶
Open says whether the task is still to do: its category is neither done nor dropped.
func (Task) ReviewDue ¶
ReviewDue says whether project e's interval passed at now since its last review, or since it was created when it was never reviewed.
func (Task) ReviewInterval ¶
func (Task) Role ¶
Role is the value of the property role acts on in p; a zero Value when no property takes it or it is unset.
func (*Task) SetProp ¶
SetProp sets the property name to v as by wrote it at at; a zero v unsets it. Setting the value it holds, by the writer that wrote it, changes nothing.
type UnitFacts ¶
type UnitFacts struct {
Unit unit.Unit
StartedByMe bool
ClosurePosted bool
Cares bool // followed/watched by the user, or the user's own unit
Carded bool // the unit's card is stored, so Cares says what its plugin reported
LastHuman time.Time // newest human event not by the user (card.LastHuman when !Who.Is(Me))
// Kind is the value of the kind property the unit's plugin gives the tasks of its units, such as thread;
// "" gives none.
Kind string
}
UnitFacts are what the rules need beyond the items, from the plugin's card.
type Value ¶
type Value struct {
Text string `json:"text,omitempty"`
Int int64 `json:"int,omitempty"`
Time time.Time `json:"time,omitzero"`
Dur time.Duration `json:"dur,omitempty"`
Actors []items.Person `json:"actors,omitempty"`
List []string `json:"list,omitempty"`
}
Value is a property's value: the field its PropType names is set, the others are zero. Text holds string and enum, Int int, Time date, Dur duration, Actors actor and actor[] (one person for actor), List string[].
type Verb ¶
type Verb string
const ( VerbNext Verb = "next" VerbWaiting Verb = "waiting" VerbSchedule Verb = "schedule" VerbWake Verb = "wake" VerbSomeday Verb = "someday" VerbReference Verb = "reference" VerbFocus Verb = "focus" VerbProject Verb = "project" VerbApprove Verb = "approve" VerbDelegate Verb = "delegate" VerbDone Verb = "done" VerbDismiss Verb = "dismiss" VerbSeen Verb = "seen" VerbContext Verb = "context" VerbArea Verb = "area" VerbAnswer Verb = "answer" VerbEdit Verb = "edit" // drafts only, registered by the outbox VerbRetry Verb = "retry" VerbReply Verb = "reply" // a draft the user writes on the task's unit, served by the daemon )