oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package chat
2
3import (
4 "context"
5
6 "gorm.io/gorm"
7)
8
9// StepModels is the model each of the person's own steps ran on, as its
10// harness reported it with the attempt's usage (the newest row wins). A
11// step that has not reported usage yet, or that ran on someone else's
12// runner, is absent: the model is unknown, never guessed.
13func (s *Store) StepModels(ctx context.Context, person string, steps []string) (map[string]string, error) {
14 out := map[string]string{}
15 if len(steps) == 0 {
16 return out, nil
17 }
18 err := s.read(ctx, func(tx *gorm.DB) error {
19 if err := s.authority.CurrentPerson(ctx, tx); err != nil {
20 return err
21 }
22 var rows []usageRecord
23 if err := tx.Select("step_id", "model", "recorded_at", "id").Where("person = ? AND step_id IN ? AND model <> ''", person, steps).Order("recorded_at, id").Find(&rows).Error; err != nil {
24 return err
25 }
26 for _, r := range rows {
27 out[r.StepID] = r.Model
28 }
29 return nil
30 })
31 return out, err
32}
33