mirror of
https://github.com/tobiasehlert/teslamateapi.git
synced 2026-02-27 09:54:18 +08:00
adding sql when end_date is not null to charges
This commit is contained in:
@@ -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{}
|
||||
|
||||
@@ -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{}
|
||||
|
||||
Reference in New Issue
Block a user