summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-01-08 22:14:00 +0100
committertechknowlogick <techknowlogick@gitea.io>2020-01-08 16:14:00 -0500
commit14a96874442a13bb212affb13a585f0536d89c2a (patch)
treef5406f59da2da0c70ca0d4efa3af3343b02debbb /models
parentf8dcc5f9f8e389218f1908ad9d5fe2044102abf1 (diff)
downloadgitea-14a96874442a13bb212affb13a585f0536d89c2a.tar.gz
gitea-14a96874442a13bb212affb13a585f0536d89c2a.zip
times Add filters (#9373)
(extend #9200) * add query param for GET functions (created Bevore & after) * add test * generalize func GetQueryBeforeSince Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'models')
-rw-r--r--models/issue_tracked_time.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/models/issue_tracked_time.go b/models/issue_tracked_time.go
index bcb163f3c5..b84adbc59a 100644
--- a/models/issue_tracked_time.go
+++ b/models/issue_tracked_time.go
@@ -100,10 +100,12 @@ func (tl TrackedTimeList) APIFormat() api.TrackedTimeList {
// FindTrackedTimesOptions represent the filters for tracked times. If an ID is 0 it will be ignored.
type FindTrackedTimesOptions struct {
- IssueID int64
- UserID int64
- RepositoryID int64
- MilestoneID int64
+ IssueID int64
+ UserID int64
+ RepositoryID int64
+ MilestoneID int64
+ CreatedAfterUnix int64
+ CreatedBeforeUnix int64
}
// ToCond will convert each condition into a xorm-Cond
@@ -121,6 +123,12 @@ func (opts *FindTrackedTimesOptions) ToCond() builder.Cond {
if opts.MilestoneID != 0 {
cond = cond.And(builder.Eq{"issue.milestone_id": opts.MilestoneID})
}
+ if opts.CreatedAfterUnix != 0 {
+ cond = cond.And(builder.Gte{"tracked_time.created_unix": opts.CreatedAfterUnix})
+ }
+ if opts.CreatedBeforeUnix != 0 {
+ cond = cond.And(builder.Lte{"tracked_time.created_unix": opts.CreatedBeforeUnix})
+ }
return cond
}