adding sql when end_date is not null to charges

This commit is contained in:
Tobias Lindberg
2021-05-19 19:10:05 +02:00
parent 695dc389ad
commit ef40a91e8d
2 changed files with 2 additions and 12 deletions
+1 -6
View File
@@ -106,7 +106,7 @@ func TeslaMateAPICarsChargesV1(c *gin.Context) {
LEFT JOIN addresses address ON address_id = address.id
LEFT JOIN positions position ON position_id = position.id
LEFT JOIN geofences geofence ON geofence_id = geofence.id
WHERE charging_processes.car_id=$1
WHERE charging_processes.car_id=$1 AND charging_processes.end_date IS NOT NULL
ORDER BY start_date DESC
LIMIT $2 OFFSET $3;`
rows, err := db.Query(query, CarID, ResultShow, ResultPage)
@@ -121,11 +121,6 @@ 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{}
+1 -6
View File
@@ -136,7 +136,7 @@ func TeslaMateAPICarsChargesDetailsV1(c *gin.Context) {
LEFT JOIN positions position ON position_id = position.id
LEFT JOIN geofences geofence ON geofence_id = geofence.id
LEFT JOIN charges ON charging_processes.id = charges.id
WHERE charging_processes.car_id=$1 AND charging_processes.id=$2
WHERE charging_processes.car_id=$1 AND charging_processes.id=$2 AND charging_processes.end_date IS NOT NULL
ORDER BY start_date DESC;`
rows, err := db.Query(query, CarID, ChargeID)
@@ -150,11 +150,6 @@ func TeslaMateAPICarsChargesDetailsV1(c *gin.Context) {
// looping through all results
for rows.Next() {
// skip a malformed charge
if end_date == NULL {
break
}
// creating charge object based on struct
charge := Charge{}