Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tedpearson committed Oct 11, 2022
1 parent 9be19bd commit 7998642
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app

import (
"flag"
"fmt"
"log"
"os"
"time"
Expand Down Expand Up @@ -78,22 +77,26 @@ func Main() {
startDate = endDate.Add(time.Duration(-config.ExtractDays) * 48 * time.Hour).Add(time.Minute)
}

log.Println("Downloading CSV...")
path, err := DownloadCsv(config, startDate.Format("01/02/2006"), endDate.Format("01/02/2006"))
if err != nil {
log.Fatal(err)
}
fmt.Printf("file downloaded: %s", path)
log.Printf("CSV downloaded: %s\n", path)

records, err := ParseCsv(path)
if err != nil {
log.Fatal(err)
}
log.Println("Querying previous metrics...")
existingPoints, err := QueryPreviousMetrics(startDate, endDate, config.InfluxDB)
if err != nil {
log.Fatal(err)
}
log.Println("Inserting data...")
err = WriteMetrics(records, config.InfluxDB, existingPoints)
if err != nil {
log.Fatal(err)
}
log.Println("Done")
}

0 comments on commit 7998642

Please sign in to comment.