aboutsummaryrefslogtreecommitdiffstats
path: root/query/query.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-03-28 17:17:13 +0100
committerGitHub <noreply@github.com>2020-03-28 17:17:13 +0100
commit390e66eb2b3a7088cdb8a44eeaf384fe691daf4a (patch)
tree05386ddf08d7e1c2947a6fc6cf2fbd44efa19eaf /query/query.go
parent58abc6b0a35b679ac0c34579ff1cb53c8fa71af4 (diff)
parent314fcbb2293d869c33d6a76aedd148aedff6561d (diff)
downloadgit-bug-390e66eb2b3a7088cdb8a44eeaf384fe691daf4a.tar.gz
Merge pull request #355 from MichaelMure/query-parser-ast
replace the all-in-one query parser by a complete one with AST/lexer/parser
Diffstat (limited to 'query/query.go')
-rw-r--r--query/query.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/query/query.go b/query/query.go
new file mode 100644
index 00000000..a499ad38
--- /dev/null
+++ b/query/query.go
@@ -0,0 +1,49 @@
+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 {
+ Filters
+ OrderBy
+ OrderDirection
+}
+
+// NewQuery return an identity query with the default sorting (creation-desc).
+func NewQuery() *Query {
+ return &Query{
+ OrderBy: OrderByCreation,
+ OrderDirection: OrderDescending,
+ }
+}
+
+// Filters is a collection of Filter that implement a complex filter
+type Filters struct {
+ Status []bug.Status
+ Author []string
+ 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
+)