mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	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>
This commit is contained in:
		@@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user