timetable-extension #1

Open
fred.boniface wants to merge 154 commits from timetable-extension into main
Showing only changes of commit 74e9b1b344 - Show all commits

View File

@ -122,16 +122,21 @@ func runCifUpdateDownload(cfg *helpers.Configuration, metadata *dbAccess.CifMeta
return nil return nil
} }
// Wraps nrod.NrodDownload() into a function which can handle downloading data for a given day // Wraps nrod.NrodDownload() into a function which can handle downloading data for a given day.
// Note that the previous days update is the latest and is downloaded.
func fetchUpdate(t time.Time, cfg *helpers.Configuration) (io.ReadCloser, error) { func fetchUpdate(t time.Time, cfg *helpers.Configuration) (io.ReadCloser, error) {
url, err := getUpdateUrl("daily") url, err := getUpdateUrl("daily")
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Append day string to URL // Calcuates the day yesterday which is the file that needs downloading
url = url + getDayString(t) updateDay := t.Add(-24 * time.Hour)
// Append day string to URL
url = url + getDayString(updateDay)
log.Debug("Fetching CIF Data", zap.Time("Update_File_Produced", updateDay))
dataStream, err := nrod.NrodStream(url, cfg) dataStream, err := nrod.NrodStream(url, cfg)
if err != nil { if err != nil {
return nil, err return nil, err