Fix: Events query performance improvements (#1930)

* fix: split up event queries for perf

* fix: refs

* fix: event join
This commit is contained in:
Matt Kaye
2025-07-01 11:58:15 -04:00
committed by GitHub
parent 23bdbbd8a3
commit c805a52e38
4 changed files with 323 additions and 240 deletions

View File

@@ -6,7 +6,7 @@ import (
"github.com/google/uuid"
"github.com/hatchet-dev/hatchet/api/v1/server/oas/gen"
"github.com/hatchet-dev/hatchet/pkg/repository/v1/sqlcv1"
v1 "github.com/hatchet-dev/hatchet/pkg/repository/v1"
)
func parseTriggeredRuns(triggeredRuns []byte) ([]gen.V1EventTriggeredRun, error) {
@@ -49,7 +49,7 @@ func parseTriggeredRuns(triggeredRuns []byte) ([]gen.V1EventTriggeredRun, error)
return result, nil
}
func ToV1EventList(events []*sqlcv1.ListEventsRow, limit, offset, total int64) gen.V1EventList {
func ToV1EventList(events []*v1.ListEventsRow, limit, offset, total int64) gen.V1EventList {
rows := make([]gen.V1Event, len(events))
numPages := int64(math.Ceil(float64(total) / float64(limit)))
@@ -86,15 +86,15 @@ func ToV1EventList(events []*sqlcv1.ListEventsRow, limit, offset, total int64) g
Id: row.EventExternalID.String(),
},
WorkflowRunSummary: gen.V1EventWorkflowRunSummary{
Cancelled: row.CancelledCount.Int64,
Succeeded: row.CompletedCount.Int64,
Queued: row.QueuedCount.Int64,
Failed: row.FailedCount.Int64,
Running: row.RunningCount.Int64,
Cancelled: row.CancelledCount,
Succeeded: row.CompletedCount,
Queued: row.QueuedCount,
Failed: row.FailedCount,
Running: row.RunningCount,
},
Payload: &payload,
SeenAt: &row.EventSeenAt.Time,
Scope: &row.EventScope.String,
Scope: &row.EventScope,
TriggeredRuns: &triggeredRuns,
}
}