From 314fcbb2293d869c33d6a76aedd148aedff6561d Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sun, 22 Mar 2020 13:53:34 +0100 Subject: query: no need for an ast package --- query/query.go | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 query/query.go (limited to 'query/query.go') 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 +) -- cgit v1.2.3