Mercurial > code > home > repos > gcalendarwatch
view calsync/sync_cal.go @ 81:79320eff10f2
support status=="cancelled" to delete events
author | drewp@bigasterisk.com |
---|---|
date | Fri, 06 Sep 2024 18:26:13 -0700 |
parents | 19e3def953e1 |
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 }