|
|
@ -127,6 +127,7 @@ func (l *Loader) FindLog(ctx context.Context, id string) (*models.LogResult, err |
|
|
|
} |
|
|
|
|
|
|
|
result.Task, _ = l.DB.Tasks().Find(ctx, id) |
|
|
|
result.Item, _ = l.DB.Items().Find(ctx, log.ItemID) |
|
|
|
|
|
|
|
return result, nil |
|
|
|
} |
|
|
@ -139,8 +140,10 @@ func (l *Loader) ListLogs(ctx context.Context, filter models.LogFilter) ([]*mode |
|
|
|
} |
|
|
|
|
|
|
|
taskIDs := stringset.New() |
|
|
|
itemIDs := stringset.New() |
|
|
|
for _, log := range logs { |
|
|
|
taskIDs.Add(log.TaskID) |
|
|
|
itemIDs.Add(log.ItemID) |
|
|
|
} |
|
|
|
tasks, err := l.DB.Tasks().List(ctx, models.TaskFilter{ |
|
|
|
UserID: auth.UserID(ctx), |
|
|
@ -149,6 +152,13 @@ func (l *Loader) ListLogs(ctx context.Context, filter models.LogFilter) ([]*mode |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
items, err := l.DB.Items().List(ctx, models.ItemFilter{ |
|
|
|
UserID: auth.UserID(ctx), |
|
|
|
IDs: itemIDs.Strings(), |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
results := make([]*models.LogResult, len(logs)) |
|
|
|
for i, log := range logs { |
|
|
@ -163,6 +173,13 @@ func (l *Loader) ListLogs(ctx context.Context, filter models.LogFilter) ([]*mode |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for _, item := range items { |
|
|
|
if item.ID == log.ItemID { |
|
|
|
results[i].Item = item |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return results, nil |
|
|
@ -495,6 +512,8 @@ func (l *Loader) populateGoals(ctx context.Context, goal *models.Goal) (*models. |
|
|
|
result.CompletedAmount += item.GroupWeight |
|
|
|
break |
|
|
|
} |
|
|
|
|
|
|
|
resultLog.Item = &item.Item |
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|