From 76d4bef105b2069203b4c475cb64c1085de45461 Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Fri, 12 Dec 2025 17:04:15 +0900 Subject: [PATCH] appview/{db,models}: use pipeline at-uri for indexing Change-Id: yrvlkmroppzoworpyvqrwrovumrooqvz avoid using `.Knot` and `.Rkey` directly Signed-off-by: Seongmin Lee --- appview/db/pipeline.go | 12 ++++++------ appview/models/pipeline.go | 10 ++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/appview/db/pipeline.go b/appview/db/pipeline.go index 5afa3c59..bd5e19c3 100644 --- a/appview/db/pipeline.go +++ b/appview/db/pipeline.go @@ -6,6 +6,7 @@ import ( "strings" "time" + "github.com/bluesky-social/indigo/atproto/syntax" "tangled.org/core/appview/models" "tangled.org/core/orm" ) @@ -216,7 +217,7 @@ func GetPipelineStatuses(e Execer, limit int, filters ...orm.Filter) ([]models.P } defer rows.Close() - pipelines := make(map[string]models.Pipeline) + pipelines := make(map[syntax.ATURI]models.Pipeline) for rows.Next() { var p models.Pipeline var t models.Trigger @@ -253,8 +254,7 @@ func GetPipelineStatuses(e Execer, limit int, filters ...orm.Filter) ([]models.P p.Trigger = &t p.Statuses = make(map[string]models.WorkflowStatus) - k := fmt.Sprintf("%s/%s", p.Knot, p.Rkey) - pipelines[k] = p + pipelines[p.AtUri()] = p } // get all statuses @@ -314,10 +314,10 @@ func GetPipelineStatuses(e Execer, limit int, filters ...orm.Filter) ([]models.P return nil, fmt.Errorf("invalid status created timestamp %q: %w", created, err) } - key := fmt.Sprintf("%s/%s", ps.PipelineKnot, ps.PipelineRkey) + pipelineAt := ps.PipelineAt() // extract - pipeline, ok := pipelines[key] + pipeline, ok := pipelines[pipelineAt] if !ok { continue } @@ -331,7 +331,7 @@ func GetPipelineStatuses(e Execer, limit int, filters ...orm.Filter) ([]models.P // reassign pipeline.Statuses[ps.Workflow] = statuses - pipelines[key] = pipeline + pipelines[pipelineAt] = pipeline } var all []models.Pipeline diff --git a/appview/models/pipeline.go b/appview/models/pipeline.go index 2055810e..6617786c 100644 --- a/appview/models/pipeline.go +++ b/appview/models/pipeline.go @@ -1,11 +1,13 @@ package models import ( + "fmt" "slices" "time" "github.com/bluesky-social/indigo/atproto/syntax" "github.com/go-git/go-git/v5/plumbing" + "tangled.org/core/api/tangled" spindle "tangled.org/core/spindle/models" "tangled.org/core/workflow" ) @@ -25,6 +27,10 @@ type Pipeline struct { Statuses map[string]WorkflowStatus } +func (p *Pipeline) AtUri() syntax.ATURI { + return syntax.ATURI(fmt.Sprintf("at://did:web:%s/%s/%s", p.Knot, tangled.PipelineNSID, p.Rkey)) +} + type WorkflowStatus struct { Data []PipelineStatus } @@ -128,3 +134,7 @@ type PipelineStatus struct { Error *string ExitCode int } + +func (ps *PipelineStatus) PipelineAt() syntax.ATURI { + return syntax.ATURI(fmt.Sprintf("at://did:web:%s/%s/%s", ps.PipelineKnot, tangled.PipelineNSID, ps.PipelineRkey)) +} -- 2.43.0