feat(platform): filter vehicles by archive status
This commit is contained in:
@@ -102,6 +102,15 @@ func buildVehicleCoverageSQL(query url.Values) SQLQuery {
|
||||
case "unbound":
|
||||
having = append(having, "MAX(CASE WHEN b.vin IS NOT NULL AND b.vin <> '' THEN 1 ELSE 0 END) = 0")
|
||||
}
|
||||
switch strings.TrimSpace(query.Get("archiveStatus")) {
|
||||
case "complete":
|
||||
having = append(having, "v.vin IS NOT NULL AND v.vin <> ''")
|
||||
having = append(having, "COALESCE(NULLIF(MAX(NULLIF(s.plate, '')), ''), NULLIF(MAX(NULLIF(b.plate, '')), '')) IS NOT NULL")
|
||||
having = append(having, "NULLIF(MAX(NULLIF(b.phone, '')), '') IS NOT NULL")
|
||||
having = append(having, "NULLIF(MAX(NULLIF(b.oem, '')), '') IS NOT NULL")
|
||||
case "incomplete":
|
||||
having = append(having, "(v.vin IS NULL OR v.vin = '' OR COALESCE(NULLIF(MAX(NULLIF(s.plate, '')), ''), NULLIF(MAX(NULLIF(b.plate, '')), '')) IS NULL OR NULLIF(MAX(NULLIF(b.phone, '')), '') IS NULL OR NULLIF(MAX(NULLIF(b.oem, '')), '') IS NULL)")
|
||||
}
|
||||
switch strings.TrimSpace(query.Get("serviceStatus")) {
|
||||
case "identity_required":
|
||||
having = append(having, "MAX(CASE WHEN b.vin IS NOT NULL AND b.vin <> '' THEN 1 ELSE 0 END) = 0")
|
||||
@@ -191,6 +200,15 @@ func buildVehicleCoverageSummarySQL(query url.Values) SQLQuery {
|
||||
case "unbound":
|
||||
having = append(having, "MAX(CASE WHEN b.vin IS NOT NULL AND b.vin <> '' THEN 1 ELSE 0 END) = 0")
|
||||
}
|
||||
switch strings.TrimSpace(query.Get("archiveStatus")) {
|
||||
case "complete":
|
||||
having = append(having, "v.vin IS NOT NULL AND v.vin <> ''")
|
||||
having = append(having, "COALESCE(NULLIF(MAX(NULLIF(s.plate, '')), ''), NULLIF(MAX(NULLIF(b.plate, '')), '')) IS NOT NULL")
|
||||
having = append(having, "NULLIF(MAX(NULLIF(b.phone, '')), '') IS NOT NULL")
|
||||
having = append(having, "NULLIF(MAX(NULLIF(b.oem, '')), '') IS NOT NULL")
|
||||
case "incomplete":
|
||||
having = append(having, "(v.vin IS NULL OR v.vin = '' OR COALESCE(NULLIF(MAX(NULLIF(s.plate, '')), ''), NULLIF(MAX(NULLIF(b.plate, '')), '')) IS NULL OR NULLIF(MAX(NULLIF(b.phone, '')), '') IS NULL OR NULLIF(MAX(NULLIF(b.oem, '')), '') IS NULL)")
|
||||
}
|
||||
switch strings.TrimSpace(query.Get("serviceStatus")) {
|
||||
case "identity_required":
|
||||
having = append(having, "MAX(CASE WHEN b.vin IS NOT NULL AND b.vin <> '' THEN 1 ELSE 0 END) = 0")
|
||||
|
||||
Reference in New Issue
Block a user