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