|  |  | @ -2,6 +2,7 @@ package models | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import ( | 
			
		
	
		
			
				
					|  |  |  | 	"context" | 
			
		
	
		
			
				
					|  |  |  | 	"strings" | 
			
		
	
		
			
				
					|  |  |  | 	"time" | 
			
		
	
		
			
				
					|  |  |  | ) | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -17,6 +18,25 @@ type Goal struct { | 
			
		
	
		
			
				
					|  |  |  | 	Name            string    `json:"name" db:"name"` | 
			
		
	
		
			
				
					|  |  |  | 	Description     string    `json:"description" db:"description"` | 
			
		
	
		
			
				
					|  |  |  | 	CompositionMode string    `json:"compositionMode" db:"composition_mode"` | 
			
		
	
		
			
				
					|  |  |  | 	TaskFilter      *string   `json:"taskFilter" db:"task_filter"` | 
			
		
	
		
			
				
					|  |  |  | 	ItemFilter      *string   `json:"itemFilter" db:"item_filter"` | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | func (goal *Goal) Accepts(item *Item, task *Task) bool { | 
			
		
	
		
			
				
					|  |  |  | 	if item.GroupID != goal.GroupID { | 
			
		
	
		
			
				
					|  |  |  | 		return false | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 	if goal.ItemID != nil && item.ID != *goal.ItemID { | 
			
		
	
		
			
				
					|  |  |  | 		return false | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 	if goal.TaskFilter != nil && !strings.Contains(strings.ToLower(task.Name), *goal.TaskFilter) { | 
			
		
	
		
			
				
					|  |  |  | 		return false | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 	if goal.ItemFilter != nil && !strings.Contains(strings.ToLower(item.Name), *goal.ItemFilter) { | 
			
		
	
		
			
				
					|  |  |  | 		return false | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	return true | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | func (goal *Goal) Update(update GoalUpdate) { | 
			
		
	
	
		
			
				
					|  |  | @ -47,6 +67,18 @@ func (goal *Goal) Update(update GoalUpdate) { | 
			
		
	
		
			
				
					|  |  |  | 	if update.ClearItemID { | 
			
		
	
		
			
				
					|  |  |  | 		goal.ItemID = nil | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 	if update.TaskFilter != nil { | 
			
		
	
		
			
				
					|  |  |  | 		goal.TaskFilter = update.TaskFilter | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 	if update.ClearTaskFilter { | 
			
		
	
		
			
				
					|  |  |  | 		goal.TaskFilter = nil | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 	if update.ItemFilter != nil { | 
			
		
	
		
			
				
					|  |  |  | 		goal.ItemFilter = update.ItemFilter | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 	if update.ClearItemFilter { | 
			
		
	
		
			
				
					|  |  |  | 		goal.ItemFilter = nil | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | type GoalUpdate struct { | 
			
		
	
	
		
			
				
					|  |  | @ -56,19 +88,29 @@ type GoalUpdate struct { | 
			
		
	
		
			
				
					|  |  |  | 	Name            *string    `json:"name"` | 
			
		
	
		
			
				
					|  |  |  | 	Description     *string    `json:"description"` | 
			
		
	
		
			
				
					|  |  |  | 	ItemID          *string    `json:"itemId"` | 
			
		
	
		
			
				
					|  |  |  | 	ClearItemID     bool       `json:"clearItemID"` | 
			
		
	
		
			
				
					|  |  |  | 	Unweighted      *bool      `json:"unweighted"` | 
			
		
	
		
			
				
					|  |  |  | 	CompositionMode *string    `json:"compositionMode"` | 
			
		
	
		
			
				
					|  |  |  | 	ClearItemID     bool       `json:"clearItemID"` | 
			
		
	
		
			
				
					|  |  |  | 	TaskFilter      *string    `json:"taskFilter"` | 
			
		
	
		
			
				
					|  |  |  | 	ClearTaskFilter bool       `json:"clearTaskFilter"` | 
			
		
	
		
			
				
					|  |  |  | 	ItemFilter      *string    `json:"itemFilter"` | 
			
		
	
		
			
				
					|  |  |  | 	ClearItemFilter bool       `json:"clearItemFilter"` | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | type GoalResult struct { | 
			
		
	
		
			
				
					|  |  |  | 	Goal | 
			
		
	
		
			
				
					|  |  |  | 	Group           *Group            `json:"group"` | 
			
		
	
		
			
				
					|  |  |  | 	Items           []*GoalResultItem `json:"items"` | 
			
		
	
		
			
				
					|  |  |  | 	Logs            []*LogResult      `json:"logs"` | 
			
		
	
		
			
				
					|  |  |  | 	Logs            []*GoalResultLog  `json:"logs"` | 
			
		
	
		
			
				
					|  |  |  | 	CompletedAmount int               `json:"completedAmount"` | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | type GoalResultLog struct { | 
			
		
	
		
			
				
					|  |  |  | 	LogResult | 
			
		
	
		
			
				
					|  |  |  | 	ItemCounted          bool `json:"itemCounted"` | 
			
		
	
		
			
				
					|  |  |  | 	SecondaryItemCounted bool `json:"secondaryItemCounted"` | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | type GoalResultItem struct { | 
			
		
	
		
			
				
					|  |  |  | 	Item | 
			
		
	
		
			
				
					|  |  |  | 	CompletedAmount int `json:"completedAmount"` | 
			
		
	
	
		
			
				
					|  |  | 
 |