From 2374a3ca3726b0991c27e4a0df7821d81a9b566c Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Tue, 2 Apr 2024 21:07:01 +0100 Subject: [PATCH] Barely anything done because Lucy will not sleep. --- src/cif/check.go | 2 +- src/cif/process.go | 11 +++++++++++ src/cif/update.go | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cif/check.go b/src/cif/check.go index fd23cc3..b6e7868 100644 --- a/src/cif/check.go +++ b/src/cif/check.go @@ -41,7 +41,7 @@ func parseMetadata(metadata *dbAccess.CifMetadata, cfg *helpers.Configuration) e } log.Msg.Debug("Requesting CIF Data Update") - newMeta, err := runUpdate("daily", metadata) + newMeta, err := runUpdate(metadata, cfg) if err != nil { return err } diff --git a/src/cif/process.go b/src/cif/process.go index 470a27d..185ca6e 100644 --- a/src/cif/process.go +++ b/src/cif/process.go @@ -1,5 +1,16 @@ package cif +import ( + "git.fjla.uk/owlboard/go-types/pkg/upstreamApi" + "git.fjla.uk/owlboard/timetable-mgr/dbAccess" +) + +// Probably looking to return some kind of array, containing the database actions. Associations aren't needed at the moment. +// however, maybe I need to process them too. I need to plan how to return the data properly. +func parseCifData(data []byte, metadata *dbAccess.CifMetadata) (*[]upstreamApi.CifScheduleSegment, error) { + return nil, nil +} + // Handles documents from CIF and VSTP Feeds. // Takes in individual documents, and returns them in the correct format for the Database // Uses types declared in owlboard/go-types/db diff --git a/src/cif/update.go b/src/cif/update.go index 06c3b38..7d78c88 100644 --- a/src/cif/update.go +++ b/src/cif/update.go @@ -55,6 +55,7 @@ func runUpdate(metadata *dbAccess.CifMetadata, cfg *helpers.Configuration) (*dbA newMeta, err := runFullUpdate(cfg) if err != nil { log.Msg.Error("CIF Update failed", zap.Error(err)) + return nil, err } return newMeta, nil } @@ -72,6 +73,8 @@ func runUpdate(metadata *dbAccess.CifMetadata, cfg *helpers.Configuration) (*dbA return dates[i].Before(dates[j]) }) + log.Msg.Info("Updating CIF Data", zap.Any("dates to update", dates)) + // Iterate over each date, fetching then parsing the data for _, date := range dates { data, err := fetchUpdate(date, cfg)