feat: wire GraphRAG API handlers, activities, and database layer
ci / test (push) Failing after 2m9s
ci / test (push) Failing after 2m9s
This commit is contained in:
@@ -454,3 +454,82 @@ func (db *DB) FetchActivityTraces(ctx context.Context, executionID string) ([]Ac
|
||||
|
||||
return traces, rows.Err()
|
||||
}
|
||||
|
||||
// GetWorkflowRelations retrieves all relations for a workflow version
|
||||
func (db *DB) GetWorkflowRelations(ctx context.Context, workflowID string, version int) ([]WorkflowRelation, error) {
|
||||
var relations []WorkflowRelation
|
||||
|
||||
query := `
|
||||
SELECT id, workflow_id, version, source_node_id, target_node_id,
|
||||
relation_type, label, relation_wording, metadata, created_at
|
||||
FROM workflow_relations
|
||||
WHERE workflow_id = $1 AND version = $2
|
||||
ORDER BY created_at DESC
|
||||
`
|
||||
|
||||
rows, err := db.conn.QueryContext(ctx, query, workflowID, version)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to query relations: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
var rel WorkflowRelation
|
||||
if err := rows.Scan(
|
||||
&rel.ID,
|
||||
&rel.WorkflowID,
|
||||
&rel.Version,
|
||||
&rel.SourceNodeID,
|
||||
&rel.TargetNodeID,
|
||||
&rel.RelationType,
|
||||
&rel.Label,
|
||||
&rel.RelationWording,
|
||||
&rel.Metadata,
|
||||
&rel.CreatedAt,
|
||||
); err != nil {
|
||||
return nil, fmt.Errorf("failed to scan relation: %w", err)
|
||||
}
|
||||
relations = append(relations, rel)
|
||||
}
|
||||
|
||||
return relations, rows.Err()
|
||||
}
|
||||
|
||||
// GetRelationVersions retrieves version history for a specific relation
|
||||
func (db *DB) GetRelationVersions(ctx context.Context, workflowID string, edgeID string) ([]WorkflowRelationVersion, error) {
|
||||
var versions []WorkflowRelationVersion
|
||||
|
||||
query := `
|
||||
SELECT id, workflow_id, edge_id, version_num, operation, snapshot,
|
||||
changed_at, changed_by, fields_changed
|
||||
FROM workflow_relation_versions
|
||||
WHERE workflow_id = $1 AND edge_id = $2
|
||||
ORDER BY version_num ASC
|
||||
`
|
||||
|
||||
rows, err := db.conn.QueryContext(ctx, query, workflowID, edgeID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to query relation versions: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
var v WorkflowRelationVersion
|
||||
if err := rows.Scan(
|
||||
&v.ID,
|
||||
&v.WorkflowID,
|
||||
&v.EdgeID,
|
||||
&v.VersionNum,
|
||||
&v.Operation,
|
||||
&v.Snapshot,
|
||||
&v.ChangedAt,
|
||||
&v.ChangedBy,
|
||||
&v.FieldsChanged,
|
||||
); err != nil {
|
||||
return nil, fmt.Errorf("failed to scan version: %w", err)
|
||||
}
|
||||
versions = append(versions, v)
|
||||
}
|
||||
|
||||
return versions, rows.Err()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user