id print change
This commit is contained in:
@@ -169,7 +169,7 @@ func FetchData() (*Data, error) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := client.Get("https://api.entur.io/realtime/v1/rest/et?useOriginalId=true&maxSize=100000")
|
resp, err := client.Get("https://api.entur.io/realtime/v1/rest/et?useOriginalId=true&maxSize=10")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func InsertOrUpdateEstimatedVehicleJourney(db *sql.DB, values []interface{}) error {
|
func InsertOrUpdateEstimatedVehicleJourney(db *sql.DB, values []interface{}) (int, string, error) {
|
||||||
query := `
|
query := `
|
||||||
INSERT INTO estimatedvehiclejourney (servicedelivery, recordedattime, lineref, directionref, datasource, datedvehiclejourneyref, vehiclemode, dataframeref, originref, destinationref, operatorref, vehicleref, cancellation, other)
|
INSERT INTO estimatedvehiclejourney (servicedelivery, recordedattime, lineref, directionref, datasource, datedvehiclejourneyref, vehiclemode, dataframeref, originref, destinationref, operatorref, vehicleref, cancellation, other)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)
|
||||||
@@ -26,7 +26,7 @@ func InsertOrUpdateEstimatedVehicleJourney(db *sql.DB, values []interface{}) err
|
|||||||
|
|
||||||
stmt, err := db.Prepare(query)
|
stmt, err := db.Prepare(query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error preparing statement: %v", err)
|
return 0, "", fmt.Errorf("error preparing statement: %v", err)
|
||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|
||||||
@@ -34,10 +34,8 @@ func InsertOrUpdateEstimatedVehicleJourney(db *sql.DB, values []interface{}) err
|
|||||||
var id int
|
var id int
|
||||||
err = stmt.QueryRow(values...).Scan(&action, &id)
|
err = stmt.QueryRow(values...).Scan(&action, &id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error executing statement: %v", err)
|
return 0, "", fmt.Errorf("error executing statement: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Action: %s, ID: %d\n", action, id)
|
return id, action, nil
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,9 +136,11 @@ func DBData(data *data.Data) {
|
|||||||
values = append(values, otherJson)
|
values = append(values, otherJson)
|
||||||
|
|
||||||
// Insert or update the record
|
// Insert or update the record
|
||||||
err = database.InsertOrUpdateEstimatedVehicleJourney(db, values)
|
id, action, err := database.InsertOrUpdateEstimatedVehicleJourney(db, values)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error inserting/updating estimated vehicle journey: %v\n", err)
|
fmt.Printf("Error inserting/updating estimated vehicle journey: %v\n", err)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Action: %s, ID: %d\n", action, id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user