fix(go): skip empty frames in realtime snapshot
This commit is contained in:
@@ -35,6 +35,9 @@ func (w *SnapshotWriter) Update(ctx context.Context, env envelope.FrameEnvelope)
|
||||
if vehicleKey == "" || strings.HasSuffix(vehicleKey, ":unknown") {
|
||||
return nil
|
||||
}
|
||||
if !hasRealtimePayload(env) {
|
||||
return nil
|
||||
}
|
||||
fieldsJSON, err := marshalObject(env.Fields)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -82,6 +85,16 @@ func nullableTime(ms int64) any {
|
||||
return time.UnixMilli(ms)
|
||||
}
|
||||
|
||||
func hasRealtimePayload(env envelope.FrameEnvelope) bool {
|
||||
if len(env.Fields) > 0 {
|
||||
return true
|
||||
}
|
||||
if _, ok := env.Parsed["data_units"]; ok {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const realtimeSnapshotTableSQL = `CREATE TABLE IF NOT EXISTS vehicle_realtime_snapshot (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
protocol VARCHAR(32) NOT NULL,
|
||||
|
||||
Reference in New Issue
Block a user