progress things

This commit is contained in:
Peder Vatn Austad
2024-12-27 19:00:15 +01:00
parent 5fd16ff73c
commit af676eff6e
3 changed files with 27 additions and 1 deletions

View File

@@ -169,6 +169,7 @@ func FetchData() (*Data, error) {
},
}
start := time.Now()
resp, err := client.Get("https://api.entur.io/realtime/v1/rest/et?useOriginalId=true&maxSize=100000&requestorId=ti1ASDASDDAAWdfs")
if err != nil {
return nil, err
@@ -182,5 +183,13 @@ func FetchData() (*Data, error) {
return nil, err
}
elapsed := time.Since(start)
contentLength := resp.ContentLength / (1024 * 1024) // Convert bytes to MB
if contentLength < 0 {
contentLength = 0 // If ContentLength is unknown, set to 0
}
println("Download took", elapsed.Seconds(), "seconds and downloaded", contentLength, "MB")
return data, nil
}