Skip Malformed Rows (those missing an end_date)

*Expected*
The Charges endpoint should still return data, even if a portion of charges have corrupted data.

*How it happens*
Charges can become corrupted if Teslamate does not detect that a charge ever ended, such as if the car or Teslamate goes offline when the charging ends.

*Note*
The charging_processes table's most recent row may be missing an end_date if the charge is in progress. These charges were already being skipped in the chargingDetails endpoint. I am assuming it is safe to skip them here, since they essentially have no data until the charge finishes.

*Please Test*
- Please test that this still builds as I am not entirely familiar with Go and am unsure how to test this on my docker container.
This commit is contained in:
Alec O'Connor
2021-05-04 09:39:07 -04:00
committed by GitHub
parent 6633a2c60a
commit 36cb82db87
+5
View File
@@ -121,6 +121,11 @@ func TeslaMateAPICarsChargesV1(c *gin.Context) {
// looping through all results
for rows.Next() {
// skip any malformed rows
if end_date == NULL {
continue
}
// creating charge object based on struct
charge := Charges{}