package queries import ( "context" "github.com/pharos-ai-factory/pharos-platform/services/beto/contexts/project/application/ports" "github.com/pharos-ai-factory/pharos-platform/services/beto/contexts/project/application/readmodels" foundation "github.com/pharos-ai-factory/pharos-platform/services/beto/foundation/application" "time" ) type GetProjectIntegrationSnapshotQuery struct{ ProjectID string } type GetProjectIntegrationSnapshotQueryHandler struct { Authoriser ports.Authoriser Repository ports.ProjectIntegrationReadRepository Clock foundation.Clock Freshness time.Duration } func (h GetProjectIntegrationSnapshotQueryHandler) Handle(ctx context.Context, caller ports.Caller, query GetProjectIntegrationSnapshotQuery) (readmodels.IntegrationSnapshot, error) { access := ports.Access{Operation: "GetProjectIntegrationSnapshot", ProjectID: query.ProjectID} if err := ports.RequireAccess(ctx, h.Authoriser, caller, access); err != nil { return readmodels.IntegrationSnapshot{}, err } record, err := readProject(ctx, h.Repository, query.ProjectID) if err != nil { return readmodels.IntegrationSnapshot{}, err } if err := ports.RequireProjectReadAccess(ctx, h.Authoriser, caller, access, record); err != nil { return readmodels.IntegrationSnapshot{}, err } status, err := evaluateSource(record, h.Clock, h.Freshness) if err != nil { return readmodels.IntegrationSnapshot{}, err } return readmodels.IntegrationSnapshot{Project: readmodels.Canonical(record.Snapshot, record.Revision), SourceStatus: status}, nil }