entities

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DummyItemFactory = factory.NewFactory(
	&Item{},
).SeqInt("Id", func(n int) (interface{}, error) {
	return n, nil
}).Attr("Type", func(args factory.Args) (interface{}, error) {
	return "note", nil
}).Attr("Title", func(args factory.Args) (interface{}, error) {
	return "note", nil
}).Attr("Description", func(args factory.Args) (interface{}, error) {
	return "my description", nil
}).Attr("IsStarred", func(args factory.Args) (interface{}, error) {
	return randomdata.Boolean(), nil
}).Attr("Tags", func(args factory.Args) (interface{}, error) {
	len := randomdata.Number(0, 5)
	var tags = make([]string, len)
	for i := 0; i < len; i++ {
		tags[i] = randomdata.SillyName()
	}
	return tags, nil
})

Functions

func GenerateDummyRawItem

func GenerateDummyRawItem() map[string]interface{}

func GenerateDummyRawItems

func GenerateDummyRawItems(size int) map[string]map[string]interface{}

func GetId

func GetId(data map[string]interface{}) int

func IsPending added in v0.0.2

func IsPending(status string) bool

Types

type Item

type Item struct {
	Id          int       `json:"id"`
	Title       string    `json:"title"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"created_at"`
	IsStarred   bool      `json:"is_starred"`
	Tags        []string  `json:"tags"`
	Type        string    `json:"type"`
}

func (*Item) GetCreationDateTime

func (item *Item) GetCreationDateTime() time.Time

func (*Item) GetDueDate added in v0.0.2

func (item *Item) GetDueDate() *time.Time

func (*Item) GetId

func (item *Item) GetId() int

func (*Item) GetStatus

func (item *Item) GetStatus() string

func (*Item) GetTags

func (item *Item) GetTags() []string

func (*Item) GetTitle

func (item *Item) GetTitle() string

func (*Item) GetType

func (item *Item) GetType() string

func (*Item) HasAnyTag added in v0.0.2

func (item *Item) HasAnyTag(tags ...string) bool

func (*Item) HasStar

func (item *Item) HasStar() bool

func (*Item) HasTag added in v0.0.2

func (item *Item) HasTag(tag string) bool

func (*Item) Star

func (item *Item) Star()

func (*Item) Unstar

func (item *Item) Unstar()

type ItemCollection

type ItemCollection []Manageable

func (ItemCollection) Exclude added in v0.0.2

func (c ItemCollection) Exclude(predicate ItemPredicate) ItemCollection

func (ItemCollection) Filter added in v0.0.2

func (c ItemCollection) Filter(predicate ItemPredicate) ItemCollection

func (ItemCollection) FilterByCreationDate added in v0.0.2

func (c ItemCollection) FilterByCreationDate(fromDate, toDate *time.Time) ItemCollection

func (ItemCollection) FilterByStatus added in v0.0.2

func (c ItemCollection) FilterByStatus(status string) ItemCollection

func (ItemCollection) FilterByTag added in v0.0.2

func (c ItemCollection) FilterByTag(tag string) ItemCollection

func (ItemCollection) FilterByTags added in v0.0.2

func (c ItemCollection) FilterByTags(tags ...string) ItemCollection

func (ItemCollection) FilterByType added in v0.0.2

func (c ItemCollection) FilterByType(kind string) ItemCollection

func (ItemCollection) FilterPending added in v0.0.2

func (c ItemCollection) FilterPending() ItemCollection

func (ItemCollection) Len

func (c ItemCollection) Len() int

Sort Protocol

func (ItemCollection) Less

func (c ItemCollection) Less(i, j int) bool

func (ItemCollection) Swap

func (c ItemCollection) Swap(i, j int)

type ItemFactory

type ItemFactory interface {
	Create(data map[string]interface{}) Manageable
}

type ItemPredicate added in v0.0.2

type ItemPredicate func(item Manageable) bool

type Manageable

type Manageable interface {
	GetId() int
	GetTitle() string
	GetTags() []string
	GetType() string
	GetStatus() string
	GetCreationDateTime() time.Time
	HasStar() bool
	Star()
	Unstar()
	GetDueDate() *time.Time
	HasTag(tag string) bool
	HasAnyTag(tags ...string) bool
}

func CreateItem

func CreateItem(item map[string]interface{}) Manageable

type Note

type Note struct {
	Item
}

func NewNote

func NewNote(title string, description string, tags ...string) *Note

type NoteFactory

type NoteFactory struct{}

func (*NoteFactory) Create

func (factory *NoteFactory) Create(data map[string]interface{}) Manageable

type Priority added in v0.0.2

type Priority uint
const (
	UNKNOWN  Priority = 0
	TRIVIAL  Priority = 2
	LOW      Priority = 4
	MEDIUM   Priority = 8
	HIGH     Priority = 16
	CRITICAL Priority = 32
)

type Task

type Task struct {
	Item
	Status              TaskStatus `json:"status"`
	Priority            Priority   `json:"priority"`
	DueDate             time.Time  `json:"due_date"`
	CompletedPercentage uint       `json:"completed_percentage"`
	DurationInMinutes   uint       `json:"duration_in_minutes"`
	StartedAt           time.Time  `json:"started_at"`
	CompletedAt         time.Time  `json:"completed_at"`
	CancelledAt         time.Time  `json:"cancelled_at"`
	Logs                []TaskLog  `json:"logs"`
	// contains filtered or unexported fields
}

func NewTask

func NewTask(title string, description string, status TaskStatus, tags ...string) *Task

func (*Task) GetDueDate added in v0.0.2

func (task *Task) GetDueDate() *time.Time

func (*Task) GetStatus

func (task *Task) GetStatus() string

func (*Task) TriggerEvent

func (task *Task) TriggerEvent(event string, args ...interface{}) error

type TaskFactory

type TaskFactory struct{}

func (*TaskFactory) Create

func (factory *TaskFactory) Create(data map[string]interface{}) Manageable

type TaskLog added in v0.0.2

type TaskLog struct {
	StartedAt time.Time `json:"started_at"`
	PausedAt  time.Time `json:"paused_at"`
}

type TaskStatus

type TaskStatus string
const (
	ToDo       TaskStatus = "todo"
	InProgress TaskStatus = "in-progress"
	Stopped    TaskStatus = "stopped"
	Completed  TaskStatus = "completed"
	Cancelled  TaskStatus = "cancelled"
)

Jump to

Keyboard shortcuts

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