refactor(go): avoid duplicate realtime protocol payloads

This commit is contained in:
lingniu
2026-07-02 21:09:07 +08:00
parent da78a989b5
commit d1e28b9e64
6 changed files with 23 additions and 28 deletions

View File

@@ -92,7 +92,6 @@ func (r *Repository) Update(ctx context.Context, env envelope.FrameEnvelope) err
VIN: vin,
Fields: map[string]any{},
FieldTimesMS: map[string]int64{},
ProtocolData: map[envelope.Protocol]map[string]any{},
}
} else if merged.VIN == "" && vin != "" {
merged.VIN = vin
@@ -105,10 +104,6 @@ func (r *Repository) Update(ctx context.Context, env envelope.FrameEnvelope) err
merged.SourceEndpoint = env.SourceEndpoint
}
merged.Protocols = protocols
if merged.ProtocolData == nil {
merged.ProtocolData = map[envelope.Protocol]map[string]any{}
}
merged.ProtocolData[env.Protocol] = cloneMap(protocolSnapshot.Parsed)
merged.UpdatedAtMS = nowMS
if err := r.setJSON(ctx, mergedKey(vehicleKey), merged, r.cfg.ttl()); err != nil {
return err