refactor(go): trim realtime mysql business columns
This commit is contained in:
@@ -62,9 +62,6 @@ func (w *SnapshotWriter) Update(ctx context.Context, env envelope.FrameEnvelope)
|
||||
string(env.Protocol),
|
||||
vin,
|
||||
plate,
|
||||
strings.TrimSpace(env.MessageID),
|
||||
env.Sequence,
|
||||
strings.TrimSpace(env.SourceEndpoint),
|
||||
eventTime,
|
||||
receivedAt,
|
||||
env.StableEventID(),
|
||||
@@ -79,9 +76,6 @@ func (w *SnapshotWriter) Update(ctx context.Context, env envelope.FrameEnvelope)
|
||||
location.Protocol,
|
||||
location.VIN,
|
||||
location.Plate,
|
||||
location.MessageID,
|
||||
location.Sequence,
|
||||
location.SourceEndpoint,
|
||||
location.EventTime,
|
||||
location.Latitude,
|
||||
location.Longitude,
|
||||
@@ -136,10 +130,16 @@ func (w *SnapshotWriter) dropObsoleteColumns(ctx context.Context) error {
|
||||
{table: "vehicle_realtime_snapshot", name: "vehicle_key"},
|
||||
{table: "vehicle_realtime_snapshot", name: "phone"},
|
||||
{table: "vehicle_realtime_snapshot", name: "device_id"},
|
||||
{table: "vehicle_realtime_snapshot", name: "message_id"},
|
||||
{table: "vehicle_realtime_snapshot", name: "sequence_id"},
|
||||
{table: "vehicle_realtime_snapshot", name: "source_endpoint"},
|
||||
{table: "vehicle_realtime_location", name: "fields_json"},
|
||||
{table: "vehicle_realtime_location", name: "vehicle_key"},
|
||||
{table: "vehicle_realtime_location", name: "phone"},
|
||||
{table: "vehicle_realtime_location", name: "device_id"},
|
||||
{table: "vehicle_realtime_location", name: "message_id"},
|
||||
{table: "vehicle_realtime_location", name: "sequence_id"},
|
||||
{table: "vehicle_realtime_location", name: "source_endpoint"},
|
||||
} {
|
||||
exists, err := columnExists(ctx, queryer, column.table, column.name)
|
||||
if err != nil {
|
||||
@@ -237,9 +237,6 @@ type realtimeLocationRow struct {
|
||||
Protocol string
|
||||
VIN string
|
||||
Plate string
|
||||
MessageID string
|
||||
Sequence uint16
|
||||
SourceEndpoint string
|
||||
EventTime any
|
||||
Latitude float64
|
||||
Longitude float64
|
||||
@@ -264,9 +261,6 @@ func realtimeLocationFromEnvelope(env envelope.FrameEnvelope, vin string, plate
|
||||
Protocol: string(env.Protocol),
|
||||
VIN: vin,
|
||||
Plate: plate,
|
||||
MessageID: strings.TrimSpace(env.MessageID),
|
||||
Sequence: env.Sequence,
|
||||
SourceEndpoint: strings.TrimSpace(env.SourceEndpoint),
|
||||
EventTime: nullableTime(env.EventTimeMS),
|
||||
Latitude: latitude,
|
||||
Longitude: longitude,
|
||||
@@ -394,9 +388,6 @@ const realtimeSnapshotTableSQL = `CREATE TABLE IF NOT EXISTS vehicle_realtime_sn
|
||||
protocol VARCHAR(32) NOT NULL,
|
||||
vin VARCHAR(32) NOT NULL DEFAULT '',
|
||||
plate VARCHAR(32) NOT NULL DEFAULT '',
|
||||
message_id VARCHAR(32) NOT NULL DEFAULT '',
|
||||
sequence_id INT NOT NULL DEFAULT 0,
|
||||
source_endpoint VARCHAR(128) NOT NULL DEFAULT '',
|
||||
event_time DATETIME(3) NULL,
|
||||
received_at DATETIME(3) NULL,
|
||||
event_id VARCHAR(64) NOT NULL DEFAULT '',
|
||||
@@ -409,13 +400,10 @@ const realtimeSnapshotTableSQL = `CREATE TABLE IF NOT EXISTS vehicle_realtime_sn
|
||||
|
||||
const upsertRealtimeSnapshotSQL = `
|
||||
INSERT INTO vehicle_realtime_snapshot
|
||||
(protocol, vin, plate, message_id, sequence_id, source_endpoint, event_time, received_at, event_id)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
(protocol, vin, plate, event_time, received_at, event_id)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
plate = IF(VALUES(plate) <> '', VALUES(plate), plate),
|
||||
message_id = VALUES(message_id),
|
||||
sequence_id = VALUES(sequence_id),
|
||||
source_endpoint = VALUES(source_endpoint),
|
||||
event_time = VALUES(event_time),
|
||||
received_at = VALUES(received_at),
|
||||
event_id = VALUES(event_id),
|
||||
@@ -427,9 +415,6 @@ const realtimeLocationTableSQL = `CREATE TABLE IF NOT EXISTS vehicle_realtime_lo
|
||||
protocol VARCHAR(32) NOT NULL,
|
||||
vin VARCHAR(32) NOT NULL DEFAULT '',
|
||||
plate VARCHAR(32) NOT NULL DEFAULT '',
|
||||
message_id VARCHAR(32) NOT NULL DEFAULT '',
|
||||
sequence_id INT NOT NULL DEFAULT 0,
|
||||
source_endpoint VARCHAR(128) NOT NULL DEFAULT '',
|
||||
event_time DATETIME(3) NULL,
|
||||
latitude DECIMAL(12,6) NOT NULL,
|
||||
longitude DECIMAL(12,6) NOT NULL,
|
||||
@@ -452,15 +437,11 @@ const realtimeLocationTableSQL = `CREATE TABLE IF NOT EXISTS vehicle_realtime_lo
|
||||
|
||||
const upsertRealtimeLocationSQL = `
|
||||
INSERT INTO vehicle_realtime_location
|
||||
(protocol, vin, plate, message_id, sequence_id, source_endpoint, event_time,
|
||||
latitude, longitude, speed_kmh, total_mileage_km,
|
||||
(protocol, vin, plate, event_time, latitude, longitude, speed_kmh, total_mileage_km,
|
||||
soc_percent, altitude_m, direction_deg, alarm_flag, status_flag, received_at, event_id)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
plate = IF(VALUES(plate) <> '', VALUES(plate), plate),
|
||||
message_id = VALUES(message_id),
|
||||
sequence_id = VALUES(sequence_id),
|
||||
source_endpoint = VALUES(source_endpoint),
|
||||
event_time = VALUES(event_time),
|
||||
latitude = VALUES(latitude),
|
||||
longitude = VALUES(longitude),
|
||||
|
||||
Reference in New Issue
Block a user