Mercurial > code > home > repos > gcalendarwatch
view calsync/cal_sync.go @ 60:3b0595c2bf03
logging and small refactors
author | drewp@bigasterisk.com |
---|---|
date | Fri, 06 Sep 2024 16:41:48 -0700 |
parents | 635ff76f867c |
children |
line wrap: on
line source
package main import ( "log" "bigasterisk.com/go/gcalendarwatch/convert" "bigasterisk.com/go/gcalendarwatch/gcalclient" "bigasterisk.com/go/gcalendarwatch/mongoclient" M "bigasterisk.com/go/gcalendarwatch/mongoclienttypes" ) func updateMongoCalsToMatchGoogleOnce(mc *mongoclient.MongoClient, gc *gcalclient.GCalClient) (err error) { log.Println("updateMongoCalsToMatchGoogle") seen := make(map[string]bool) cals, err := gc.AllCalendars() if err != nil { return err } for _, serviceCal := range cals { cal := convert.MongoCalFromGoogleCal(serviceCal) log.Println(M.Prefix(cal), "syncing calendar doc") seen[cal.Url] = true err = mc.UpsertOneCal(cal) if err != nil { return err } } err = mc.DeleteCalsNotInSet(seen) log.Println("updateMongoCalsToMatchGoogle done") return err }