Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2

appview/{db,models}: use pipeline at-uri for indexing

avoid using `.Knot` and `.Rkey` directly

Signed-off-by: Seongmin Lee <git@boltless.me>

authored by boltless.me and committed by tangled.org b18bfee9 4e89384c

+16 -6
+6 -6
appview/db/pipeline.go
··· 6 6 "strings" 7 7 "time" 8 8 9 + "github.com/bluesky-social/indigo/atproto/syntax" 9 10 "tangled.org/core/appview/models" 10 11 "tangled.org/core/orm" 11 12 ) ··· 217 216 } 218 217 defer rows.Close() 219 218 220 - pipelines := make(map[string]models.Pipeline) 219 + pipelines := make(map[syntax.ATURI]models.Pipeline) 221 220 for rows.Next() { 222 221 var p models.Pipeline 223 222 var t models.Trigger ··· 254 253 p.Trigger = &t 255 254 p.Statuses = make(map[string]models.WorkflowStatus) 256 255 257 - k := fmt.Sprintf("%s/%s", p.Knot, p.Rkey) 258 - pipelines[k] = p 256 + pipelines[p.AtUri()] = p 259 257 } 260 258 261 259 // get all statuses ··· 314 314 return nil, fmt.Errorf("invalid status created timestamp %q: %w", created, err) 315 315 } 316 316 317 - key := fmt.Sprintf("%s/%s", ps.PipelineKnot, ps.PipelineRkey) 317 + pipelineAt := ps.PipelineAt() 318 318 319 319 // extract 320 - pipeline, ok := pipelines[key] 320 + pipeline, ok := pipelines[pipelineAt] 321 321 if !ok { 322 322 continue 323 323 } ··· 331 331 332 332 // reassign 333 333 pipeline.Statuses[ps.Workflow] = statuses 334 - pipelines[key] = pipeline 334 + pipelines[pipelineAt] = pipeline 335 335 } 336 336 337 337 var all []models.Pipeline
+10
appview/models/pipeline.go
··· 1 1 package models 2 2 3 3 import ( 4 + "fmt" 4 5 "slices" 5 6 "time" 6 7 7 8 "github.com/bluesky-social/indigo/atproto/syntax" 8 9 "github.com/go-git/go-git/v5/plumbing" 10 + "tangled.org/core/api/tangled" 9 11 spindle "tangled.org/core/spindle/models" 10 12 "tangled.org/core/workflow" 11 13 ) ··· 25 23 // populate when querying for reverse mappings 26 24 Trigger *Trigger 27 25 Statuses map[string]WorkflowStatus 26 + } 27 + 28 + func (p *Pipeline) AtUri() syntax.ATURI { 29 + return syntax.ATURI(fmt.Sprintf("at://did:web:%s/%s/%s", p.Knot, tangled.PipelineNSID, p.Rkey)) 28 30 } 29 31 30 32 type WorkflowStatus struct { ··· 133 127 Status spindle.StatusKind 134 128 Error *string 135 129 ExitCode int 130 + } 131 + 132 + func (ps *PipelineStatus) PipelineAt() syntax.ATURI { 133 + return syntax.ATURI(fmt.Sprintf("at://did:web:%s/%s/%s", ps.PipelineKnot, tangled.PipelineNSID, ps.PipelineRkey)) 136 134 }