aboutsummaryrefslogtreecommitdiffstats
path: root/query/query.go
blob: cce61a5434c216990163c6e1373bcc24846f8c1a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package query

import "github.com/MichaelMure/git-bug/bug"

// Query is the intermediary representation of a Bug's query. It is either
// produced by parsing a query string (ex: "status:open author:rene") or created
// manually. This query doesn't do anything by itself and need to be interpreted
// for the specific domain of application.
type Query struct {
	Search
	Filters
	OrderBy
	OrderDirection
}

// NewQuery return an identity query with the default sorting (creation-desc).
func NewQuery() *Query {
	return &Query{
		OrderBy:        OrderByCreation,
		OrderDirection: OrderDescending,
	}
}

type Search []string

// StringPair is a key/value pair of strings
type StringPair struct {
	Key   string
	Value string
}

// Filters is a collection of Filter that implement a complex filter
type Filters struct {
	Status      []bug.Status
	Author      []string
	Metadata    []StringPair
	Actor       []string
	Participant []string
	Label       []string
	Title       []string
	NoLabel     bool
}

type OrderBy int

const (
	_ OrderBy = iota
	OrderById
	OrderByCreation
	OrderByEdit
)

type OrderDirection int

const (
	_ OrderDirection = iota
	OrderAscending
	OrderDescending
)