clean up with new api

This commit is contained in:
2024-09-24 16:43:39 -05:00
parent 446f178bfd
commit 2ff320038d

View File

@@ -19,10 +19,8 @@ import (
)
var (
client *api.SyncClient
redisURL string
cronSchedule string
tzLocation *time.Location
client *api.SyncClient
tzLocation *time.Location
)
func init() {
@@ -31,13 +29,6 @@ func init() {
if err != nil {
fmt.Println(".env file not loaded")
}
// Load timezone
tzLocation, err = time.LoadLocation("America/Chicago")
if err != nil {
fmt.Println("Error loading location:", err)
os.Exit(1)
}
}
// primary is the main function that will be run by the scheduler
@@ -60,14 +51,20 @@ func primary() error {
}
func main() {
redisURL = os.Getenv("REDIS_URL")
cronSchedule = os.Getenv("CRON_SCHEDULE")
client = api.NewSyncClient(os.Getenv("TODOIST_API_KEY"))
// redisURL := os.Getenv("REDIS_URL")
cronSchedule := os.Getenv("CRON_SCHEDULE")
// opt, _ := redis.ParseURL(redisURL)
// client := redis.NewClient(opt)
// Load timezone
tzLocation, err := time.LoadLocation("America/Chicago")
if err != nil {
fmt.Println("Error loading location:", err)
os.Exit(1)
}
client = api.NewSyncClient(os.Getenv("TODOIST_API_KEY"))
// create a scheduler
s, err := gocron.NewScheduler(gocron.WithLocation(tzLocation))
if err != nil {