query.go

 1package query
 2
 3import "github.com/MichaelMure/git-bug/entities/bug"
 4
 5// Query is the intermediary representation of a Bug's query. It is either
 6// produced by parsing a query string (ex: "status:open author:rene") or created
 7// manually. This query doesn't do anything by itself and need to be interpreted
 8// for the specific domain of application.
 9type Query struct {
10	Search
11	Filters
12	OrderBy
13	OrderDirection
14}
15
16// NewQuery return an identity query with the default sorting (creation-desc).
17func NewQuery() *Query {
18	return &Query{
19		OrderBy:        OrderByCreation,
20		OrderDirection: OrderDescending,
21	}
22}
23
24type Search []string
25
26// StringPair is a key/value pair of strings
27type StringPair struct {
28	Key   string
29	Value string
30}
31
32// Filters is a collection of Filter that implement a complex filter
33type Filters struct {
34	Status      []bug.Status
35	Author      []string
36	Metadata    []StringPair
37	Actor       []string
38	Participant []string
39	Label       []string
40	Title       []string
41	NoLabel     bool
42}
43
44type OrderBy int
45
46const (
47	_ OrderBy = iota
48	OrderById
49	OrderByCreation
50	OrderByEdit
51)
52
53type OrderDirection int
54
55const (
56	_ OrderDirection = iota
57	OrderAscending
58	OrderDescending
59)