From 14a96874442a13bb212affb13a585f0536d89c2a Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 8 Jan 2020 22:14:00 +0100 Subject: 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 --- models/issue_tracked_time.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'models') 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 } -- cgit v1.2.3