oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package equipo
2
3import (
4 "net/http"
5
6 "amadan.net/oficina/equipo/internal/equipo/planning"
7 "amadan.net/oficina/equipo/internal/equipo/team"
8
9 "gorm.io/gorm"
10)
11
12type ConnectionView struct {
13 Isolation team.IsolationSnapshot
14 Connection
15 Report ConnectionReport
16 Unconfined, Unverified, Acknowledged, Available bool
17}
18type ProjectConnectionView = planning.ProjectConnectionView
19type ConnectionOption = planning.ProjectConnectionOption
20
21func (a *application) connectionsPage(w http.ResponseWriter, r *http.Request, data pageData) {
22 err := a.store.readTeam(r.Context(), Actor{Address: data.Address}, func(tx *gorm.DB, instance Team) error {
23 var rows []connectionRecord
24 q := tx
25 if !data.Owner {
26 q = q.Where("person=?", data.Address)
27 }
28 if err := q.Order("person,id").Find(&rows).Error; err != nil {
29 return storeError(err)
30 }
31 for _, row := range rows {
32 if err := decodeConnection(&row); err != nil {
33 return err
34 }
35 for _, report := range row.Reports {
36 available, _, err := a.store.eligible(tx, row, report, a.store.runnerClock.Now())
37 if err != nil {
38 return err
39 }
40 iso, err := a.store.isolationSnapshot(tx, row, report)
41 if err != nil {
42 return err
43 }
44 data.Connections = append(data.Connections, ConnectionView{Isolation: iso, Connection: row.Connection, Report: report, Unverified: !a.store.confined(report), Available: available})
45 }
46 }
47 var err error
48 data.Choices, err = planning.ConnectionChoices(tx, data.Address, rows)
49 return storeError(err)
50 })
51 if err != nil {
52 a.failure(w, r, err)
53 return
54 }
55 data.Live = a.live.View(r)
56 a.renderLive(w, r, "connections", data)
57}
58