This commit is contained in:
+21
-5
@@ -535,11 +535,12 @@ func (l *Loader) populateGoals(ctx context.Context, goal *models.Goal) (*models.
|
||||
}
|
||||
|
||||
// Apply logs
|
||||
result.Logs = make([]*models.LogResult, 0, len(logs))
|
||||
result.Logs = make([]*models.GoalResultLog, 0, len(logs))
|
||||
for _, log := range logs {
|
||||
resultLog := &models.LogResult{
|
||||
Log: *log,
|
||||
resultLog := &models.GoalResultLog{
|
||||
LogResult: models.LogResult{Log: *log},
|
||||
}
|
||||
contributes := false
|
||||
|
||||
for _, task := range tasks {
|
||||
if task.ID == log.TaskID {
|
||||
@@ -550,7 +551,7 @@ func (l *Loader) populateGoals(ctx context.Context, goal *models.Goal) (*models.
|
||||
|
||||
for _, item := range result.Items {
|
||||
amount := log.Amount(item.ID)
|
||||
if amount > 0 && (goal.ItemID == nil || *goal.ItemID == item.ID) {
|
||||
if amount > 0 && goal.Accepts(&item.Item, resultLog.Task) {
|
||||
item.CompletedAmount += amount
|
||||
|
||||
if goal.Unweighted {
|
||||
@@ -558,21 +559,36 @@ func (l *Loader) populateGoals(ctx context.Context, goal *models.Goal) (*models.
|
||||
} else {
|
||||
result.CompletedAmount += amount * item.GroupWeight
|
||||
}
|
||||
|
||||
contributes = true
|
||||
} else {
|
||||
amount = 0
|
||||
}
|
||||
|
||||
if item.ID == log.ItemID {
|
||||
resultLog.Item = &item.Item
|
||||
|
||||
if amount > 0 {
|
||||
resultLog.ItemCounted = true
|
||||
}
|
||||
|
||||
if log.SecondaryItemID == nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if log.SecondaryItemID != nil && item.ID == *log.SecondaryItemID {
|
||||
if amount > 0 {
|
||||
resultLog.SecondaryItemCounted = true
|
||||
}
|
||||
|
||||
resultLog.SecondaryItem = &item.Item
|
||||
}
|
||||
}
|
||||
|
||||
result.Logs = append(result.Logs, resultLog)
|
||||
if contributes {
|
||||
result.Logs = append(result.Logs, resultLog)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user