Audit of 9af1463
This commit is contained in:
@@ -1021,8 +1021,8 @@ func (s *Store) TaskEvents(ctx context.Context, taskID string, after int64, limi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) TranscriptEvents(ctx context.Context, taskID string, after int64, limit int) ([]api.Event, error) {
|
func (s *Store) TranscriptEvents(ctx context.Context, taskID string, after int64, limit int) ([]api.Event, error) {
|
||||||
where := "task_id = ?"
|
query := "SELECT " + eventColumns + " FROM events WHERE task_id = ? AND seq > ?"
|
||||||
args := []any{taskID}
|
args := []any{taskID, after}
|
||||||
for id := taskID; ; {
|
for id := taskID; ; {
|
||||||
from := ""
|
from := ""
|
||||||
at := 0
|
at := 0
|
||||||
@@ -1041,14 +1041,12 @@ func (s *Store) TranscriptEvents(ctx context.Context, taskID string, after int64
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
where += " OR (task_id = ? AND seq <= ?)"
|
query += " UNION ALL SELECT " + eventColumns + " FROM events WHERE task_id = ? AND seq <= ? AND seq > ?"
|
||||||
args = append(args, from, cut)
|
args = append(args, from, cut, after)
|
||||||
id = from
|
id = from
|
||||||
}
|
}
|
||||||
rows, err := s.db.QueryContext(ctx, `
|
// Merge the indexed ranges in sequence order instead of sorting the remaining history for every page.
|
||||||
SELECT `+eventColumns+`
|
rows, err := s.db.QueryContext(ctx, query+" ORDER BY seq LIMIT ?", append(args, limit)...)
|
||||||
FROM events WHERE (`+where+`) AND seq > ? ORDER BY seq LIMIT ?
|
|
||||||
`, append(args, after, limit)...)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user