You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"SELECT event_id, sequence_id, instance_id, event_type, timestamp, schedule_event_id, attributes, visible_at FROM `history` WHERE instance_id = ? ORDER BY id",
140
-
instance.InstanceID,
141
-
)
137
+
varhistoryEvents*sql.Rows
138
+
iflastSequenceID!=nil {
139
+
historyEvents, err=tx.QueryContext(
140
+
ctx,
141
+
"SELECT event_id, sequence_id, instance_id, event_type, timestamp, schedule_event_id, attributes, visible_at FROM `history` WHERE instance_id = ? AND sequence_id > ? ORDER BY sequence_id",
142
+
instance.InstanceID,
143
+
*lastSequenceID,
144
+
)
145
+
} else {
146
+
historyEvents, err=tx.QueryContext(
147
+
ctx,
148
+
"SELECT event_id, sequence_id, instance_id, event_type, timestamp, schedule_event_id, attributes, visible_at FROM `history` WHERE instance_id = ? ORDER BY sequence_id",
149
+
instance.InstanceID,
150
+
)
151
+
}
142
152
iferr!=nil {
143
153
returnnil, errors.Wrap(err, "could not get history")
"SELECT event_id, sequence_id, instance_id, event_type, timestamp, schedule_event_id, attributes, visible_at FROM `history` WHERE instance_id = ? ORDER BY id",
398
-
instanceID,
399
-
)
400
-
iferr!=nil {
401
-
returnnil, errors.Wrap(err, "could not get history")
402
-
}
403
-
404
-
forhistoryEvents.Next() {
405
-
varinstanceIDstring
406
-
varattributes []byte
407
-
408
-
historyEvent:= history.Event{}
409
-
410
-
iferr:=historyEvents.Scan(
411
-
&historyEvent.ID,
412
-
&historyEvent.SequenceID,
413
-
&instanceID,
414
-
&historyEvent.Type,
415
-
&historyEvent.Timestamp,
416
-
&historyEvent.ScheduleEventID,
417
-
&attributes,
418
-
&historyEvent.VisibleAt,
419
-
); err!=nil {
420
-
returnnil, errors.Wrap(err, "could not scan event")
421
-
}
422
-
423
-
a, err:=history.DeserializeAttributes(historyEvent.Type, attributes)
424
-
iferr!=nil {
425
-
returnnil, errors.Wrap(err, "could not deserialize attributes")
426
-
}
427
-
428
-
historyEvent.Attributes=a
429
-
430
-
t.History=append(t.History, historyEvent)
431
-
}
432
-
} else {
433
-
// Get only most recent history event
434
-
row:=tx.QueryRowContext(ctx, "SELECT event_id, sequence_id, instance_id, event_type, timestamp, schedule_event_id, attributes, visible_at FROM `history` WHERE instance_id = ? ORDER BY id DESC LIMIT 1", instanceID)
435
-
436
-
varinstanceIDstring
437
-
varattributes []byte
438
-
439
-
lastHistoryEvent:= history.Event{}
440
-
441
-
iferr:=row.Scan(
442
-
&lastHistoryEvent.ID,
443
-
&lastHistoryEvent.SequenceID,
444
-
&instanceID,
445
-
&lastHistoryEvent.Type,
446
-
&lastHistoryEvent.Timestamp,
447
-
&lastHistoryEvent.ScheduleEventID,
448
-
&attributes,
449
-
&lastHistoryEvent.VisibleAt,
450
-
); err!=nil {
451
-
returnnil, errors.Wrap(err, "could not scan event")
452
-
}
453
-
454
-
a, err:=history.DeserializeAttributes(lastHistoryEvent.Type, attributes)
455
-
iferr!=nil {
456
-
returnnil, errors.Wrap(err, "could not deserialize attributes")
395
+
// Get most recent sequence id
396
+
row=tx.QueryRowContext(ctx, "SELECT sequence_id FROM `history` WHERE instance_id = ? ORDER BY id DESC LIMIT 1", instanceID)
397
+
iferr:=row.Scan(
398
+
&t.LastSequenceID,
399
+
); err!=nil {
400
+
iferr!=sql.ErrNoRows {
401
+
returnnil, errors.Wrap(err, "could not get most recent sequence id")
0 commit comments