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 ( var (
client *api.SyncClient client *api.SyncClient
redisURL string tzLocation *time.Location
cronSchedule string
tzLocation *time.Location
) )
func init() { func init() {
@@ -31,13 +29,6 @@ func init() {
if err != nil { if err != nil {
fmt.Println(".env file not loaded") 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 // primary is the main function that will be run by the scheduler
@@ -60,14 +51,20 @@ func primary() error {
} }
func main() { func main() {
redisURL = os.Getenv("REDIS_URL") // redisURL := os.Getenv("REDIS_URL")
cronSchedule = os.Getenv("CRON_SCHEDULE") cronSchedule := os.Getenv("CRON_SCHEDULE")
client = api.NewSyncClient(os.Getenv("TODOIST_API_KEY"))
// opt, _ := redis.ParseURL(redisURL) // opt, _ := redis.ParseURL(redisURL)
// client := redis.NewClient(opt) // 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 // create a scheduler
s, err := gocron.NewScheduler(gocron.WithLocation(tzLocation)) s, err := gocron.NewScheduler(gocron.WithLocation(tzLocation))
if err != nil { if err != nil {