feat: expand vehicle data platform capabilities
This commit is contained in:
@@ -58,48 +58,51 @@ type MetricDiagnosisQuery struct {
|
||||
}
|
||||
|
||||
type MetricRow struct {
|
||||
VIN string `json:"vin"`
|
||||
StatDate string `json:"stat_date"`
|
||||
Protocol string `json:"protocol"`
|
||||
SourceID *int64 `json:"source_id,omitempty"`
|
||||
SourceIP string `json:"source_ip,omitempty"`
|
||||
LatestSourceEndpoint string `json:"latest_source_endpoint,omitempty"`
|
||||
PlatformName string `json:"platform_name,omitempty"`
|
||||
SourceCode string `json:"source_code,omitempty"`
|
||||
SourceKind string `json:"source_kind,omitempty"`
|
||||
DailyMileageKM float64 `json:"daily_mileage_km"`
|
||||
LatestTotalMileageKM *float64 `json:"latest_total_mileage_km,omitempty"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
VIN string `json:"vin"`
|
||||
StatDate string `json:"stat_date"`
|
||||
Protocol string `json:"protocol"`
|
||||
SourceID *int64 `json:"source_id,omitempty"`
|
||||
SourceIP string `json:"source_ip,omitempty"`
|
||||
LatestSourceEndpoint string `json:"latest_source_endpoint,omitempty"`
|
||||
PlatformName string `json:"platform_name,omitempty"`
|
||||
SourceCode string `json:"source_code,omitempty"`
|
||||
SourceKind string `json:"source_kind,omitempty"`
|
||||
DailyMileageKM float64 `json:"daily_mileage_km"`
|
||||
PureHydrogenMileageKM float64 `json:"pure_hydrogen_mileage_km"`
|
||||
LatestTotalMileageKM *float64 `json:"latest_total_mileage_km,omitempty"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type MetricSourceRow struct {
|
||||
VIN string `json:"vin"`
|
||||
StatDate string `json:"stat_date"`
|
||||
Protocol string `json:"protocol"`
|
||||
SourceKey string `json:"source_key"`
|
||||
SourceIP string `json:"source_ip"`
|
||||
SourceEndpoint string `json:"source_endpoint,omitempty"`
|
||||
Phone string `json:"phone,omitempty"`
|
||||
DeviceID string `json:"device_id,omitempty"`
|
||||
PlatformName string `json:"platform_name,omitempty"`
|
||||
SourceID *int64 `json:"source_id,omitempty"`
|
||||
SourceCode string `json:"source_code,omitempty"`
|
||||
SourceKind string `json:"source_kind,omitempty"`
|
||||
SourceEnabled *bool `json:"source_enabled,omitempty"`
|
||||
TrustPriority *int `json:"trust_priority,omitempty"`
|
||||
FirstTotalMileageKM *float64 `json:"first_total_mileage_km,omitempty"`
|
||||
LatestTotalMileageKM *float64 `json:"latest_total_mileage_km,omitempty"`
|
||||
DailyMileageKM float64 `json:"daily_mileage_km"`
|
||||
SampleCount int64 `json:"sample_count"`
|
||||
FirstEventTime string `json:"first_event_time,omitempty"`
|
||||
LatestEventTime string `json:"latest_event_time,omitempty"`
|
||||
QualityStatus string `json:"quality_status"`
|
||||
QualityReason string `json:"quality_reason,omitempty"`
|
||||
IsSelected bool `json:"is_selected"`
|
||||
SelectionStatus string `json:"selection_status,omitempty"`
|
||||
SelectionReason string `json:"selection_reason,omitempty"`
|
||||
SelectionAction string `json:"selection_action,omitempty"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
VIN string `json:"vin"`
|
||||
StatDate string `json:"stat_date"`
|
||||
Protocol string `json:"protocol"`
|
||||
SourceKey string `json:"source_key"`
|
||||
SourceIP string `json:"source_ip"`
|
||||
SourceEndpoint string `json:"source_endpoint,omitempty"`
|
||||
Phone string `json:"phone,omitempty"`
|
||||
DeviceID string `json:"device_id,omitempty"`
|
||||
PlatformName string `json:"platform_name,omitempty"`
|
||||
SourceID *int64 `json:"source_id,omitempty"`
|
||||
SourceCode string `json:"source_code,omitempty"`
|
||||
SourceKind string `json:"source_kind,omitempty"`
|
||||
SourceEnabled *bool `json:"source_enabled,omitempty"`
|
||||
TrustPriority *int `json:"trust_priority,omitempty"`
|
||||
FirstTotalMileageKM *float64 `json:"first_total_mileage_km,omitempty"`
|
||||
LatestTotalMileageKM *float64 `json:"latest_total_mileage_km,omitempty"`
|
||||
DailyMileageKM float64 `json:"daily_mileage_km"`
|
||||
PureHydrogenMileageKM float64 `json:"pure_hydrogen_mileage_km"`
|
||||
PureHydrogenSampleCount int64 `json:"pure_hydrogen_sample_count"`
|
||||
SampleCount int64 `json:"sample_count"`
|
||||
FirstEventTime string `json:"first_event_time,omitempty"`
|
||||
LatestEventTime string `json:"latest_event_time,omitempty"`
|
||||
QualityStatus string `json:"quality_status"`
|
||||
QualityReason string `json:"quality_reason,omitempty"`
|
||||
IsSelected bool `json:"is_selected"`
|
||||
SelectionStatus string `json:"selection_status,omitempty"`
|
||||
SelectionReason string `json:"selection_reason,omitempty"`
|
||||
SelectionAction string `json:"selection_action,omitempty"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type MetricDiagnosisRow struct {
|
||||
@@ -241,6 +244,7 @@ func (r *MetricRepository) Query(ctx context.Context, query MetricQuery) ([]Metr
|
||||
&sourceCode,
|
||||
&sourceKind,
|
||||
&row.DailyMileageKM,
|
||||
&row.PureHydrogenMileageKM,
|
||||
&latest,
|
||||
&updatedAt,
|
||||
); err != nil {
|
||||
@@ -303,7 +307,9 @@ func (r *MetricRepository) QuerySources(ctx context.Context, query MetricSourceQ
|
||||
&firstTotal,
|
||||
&latestTotal,
|
||||
&row.DailyMileageKM,
|
||||
&row.PureHydrogenMileageKM,
|
||||
&row.SampleCount,
|
||||
&row.PureHydrogenSampleCount,
|
||||
&firstEvent,
|
||||
&latestEvent,
|
||||
&row.QualityStatus,
|
||||
@@ -1108,7 +1114,7 @@ func buildMetricSQL(query MetricQuery) (string, []any) {
|
||||
where, args := buildMetricWhere(query)
|
||||
sqlText := `SELECT m.vin, m.stat_date, m.protocol, m.source_id,
|
||||
ds.source_ip, ds.latest_source_endpoint, ds.platform_name, ds.source_code, ds.source_kind,
|
||||
m.daily_mileage_km, m.latest_total_mileage_km, m.updated_at
|
||||
m.daily_mileage_km, m.pure_hydrogen_mileage_km, m.latest_total_mileage_km, m.updated_at
|
||||
FROM vehicle_daily_mileage m
|
||||
LEFT JOIN vehicle_data_source ds ON ds.id = m.source_id`
|
||||
if len(where) > 0 {
|
||||
@@ -1124,7 +1130,8 @@ func buildMetricSourceSQL(query MetricSourceQuery) (string, []any) {
|
||||
sqlText := `SELECT s.vin, s.stat_date, s.protocol, s.source_key, s.source_ip, s.source_endpoint, s.phone, s.device_id,
|
||||
COALESCE(NULLIF(TRIM(s.platform_name), ''), ds.platform_name) AS platform_name,
|
||||
ds.id, ds.source_code, ` + metricSourceKindSQL("s") + ` AS source_kind, ds.enabled, ds.trust_priority,
|
||||
s.first_total_mileage_km, s.latest_total_mileage_km, s.daily_mileage_km, s.sample_count,
|
||||
s.first_total_mileage_km, s.latest_total_mileage_km, s.daily_mileage_km, s.pure_hydrogen_mileage_km,
|
||||
s.sample_count, s.pure_hydrogen_sample_count,
|
||||
s.first_event_time, s.latest_event_time, s.quality_status, s.quality_reason, s.is_selected, s.updated_at
|
||||
FROM vehicle_daily_mileage_source s
|
||||
LEFT JOIN vehicle_data_source ds ON ds.protocol = s.protocol AND ds.source_ip = s.source_ip`
|
||||
|
||||
Reference in New Issue
Block a user