diff --git a/main.go b/main.go index 54153cf..7d3bff7 100644 --- a/main.go +++ b/main.go @@ -12,17 +12,126 @@ import ( ) var calName = flag.String("calendar", "", "name of calendar") +var days = flag.Int("days", 0, "number of days in the future") -var students = []string{ +var allStudents = []string{ "oliver.park@heliosns.org", } +var greenStudents = []string{ + "oliver.park@heliosns.org", +} + +var weekDays = []time.Weekday{time.Monday, time.Tuesday, time.Wednesday, time.Thursday, time.Friday} +var weekDaysButFriday = []time.Weekday{time.Monday, time.Tuesday, time.Wednesday, time.Thursday} + var classes = []Class { Class{ - Summary: "Test 2", - Start: "22:00", - End: "22:30", - Days: []time.Weekday{time.Monday, time.Tuesday, time.Wednesday, time.Thursday}, + Summary: "Morning Circle", + Start: "08:30", + End: "09:00", + Days: weekDaysButFriday, + Zoom: "https://us02web.zoom.us/j/2274643506?pwd=Nm5NUXMwOVJKbEUzNE5VSkZCQzJ2UT09", + }, + Class{ + Summary: "Community Meeting", + Start: "08:30", + End: "09:00", + Days: []time.Weekday{time.Friday}, + Zoom: "https://zoom.us/j/96371462107", + }, + Class{ + Summary: "Math (Claudia & Rachel)", + Start: "09:00", + End: "09:40", + Days: weekDays, + Zoom: "https://us02web.zoom.us/j/2274643506?pwd=Nm5NUXMwOVJKbEUzNE5VSkZCQzJ2UT09", + Students: []string{ + "oliver.park@heliosns.org", + }, + }, + Class{ + Summary: "Dreambox", + Start: "09:40", + End: "10:00", + Days: weekDays, + }, + Class{ + Summary: "Theme", + Start: "10:30", + End: "11:30", + Days: weekDaysButFriday, + Zoom: "https://us02web.zoom.us/j/2274643506?pwd=Nm5NUXMwOVJKbEUzNE5VSkZCQzJ2UT09", + }, + Class{ + Summary: "SEL", + Start: "10:30", + End: "11:15", + Days: []time.Weekday{time.Friday}, + Zoom: "https://us02web.zoom.us/j/2274643506?pwd=Nm5NUXMwOVJKbEUzNE5VSkZCQzJ2UT09", + }, + Class{ + Summary: "Literacy (Green)", + Start: "11:30", + End: "12:00", + Days: []time.Weekday{time.Monday, time.Wednesday}, + Zoom: "https://us02web.zoom.us/j/2274643506?pwd=Nm5NUXMwOVJKbEUzNE5VSkZCQzJ2UT09", + Students: greenStudents, + }, + Class{ + Summary: "PE (Yellow/Green)", + Start: "11:30", + End: "12:00", + Days: []time.Weekday{time.Tuesday}, + Zoom: "https://zoom.us/j/97472507748?pwd=cW5vUFhyUjNTS2toWlZGN254U1ZqZz09", + Students: greenStudents, + }, + Class{ + Summary: "iLab (Yellow/Green)", + Start: "11:30", + End: "12:00", + Days: []time.Weekday{time.Thursday}, + Zoom: "https://us02web.zoom.us/j/86403635026?pwd=S2t1WkN2dnNJZlFkejdEbjRsUmNNUT09", + Students: greenStudents, + }, + Class{ + Summary: "Library", + Start: "11:30", + End: "12:00", + Days: []time.Weekday{time.Friday}, + Zoom: "https://us02web.zoom.us/my/helioslibrary?pwd=cWd4RjNqNXZXNjRjM2dYQVhYeS9Xdz09", + }, + Class{ + Summary: "Spanish", + Start: "12:45", + End: "13:30", + Days: []time.Weekday{time.Monday, time.Tuesday, time.Wednesday}, + Zoom: "https://zoom.us/j/95144364579?pwd=cGdwNTZIOE42Y0syeVcwVEFhZ1JxZz09", + Students: []string{ + "oliver.park@heliosns.org", + }, + }, + Class{ + Summary: "Music & Movement (Blue/Green)", + Start: "12:45", + End: "13:30", + Days: []time.Weekday{time.Friday}, + Zoom: "https://zoom.us/j/96449009866?pwd=dlBHYUwxaDRReFhjVmRKZ0Vhdjdkdz09", + Students: greenStudents, + }, + Class{ + Summary: "Art (Blue/Green)", + Start: "14:00", + End: "14:45", + Days: []time.Weekday{time.Friday}, + Zoom: "https://us02web.zoom.us/j/85434303018?pwd=c3EzQVNCMmk0L0o4bVF4QW85RTZHZz09", + Students: greenStudents, + }, + Class{ + Summary: "Closing Circle", + Start: "15:00", + End: "15:15", + Days: []time.Weekday{time.Friday}, Zoom: "https://us02web.zoom.us/j/2274643506?pwd=Nm5NUXMwOVJKbEUzNE5VSkZCQzJ2UT09", }, } @@ -81,56 +190,57 @@ func main() { now := time.Now().In(loc) - dateStr := now.Format("2006-01-02") + for i := 0; i < *days; i++ { + date := now.Add(time.Duration(i * 24) * time.Hour) + dateStr := date.Format("2006-01-02") - // TOOD: loop through days - - for _, class := range classes { - found := false - for _, day := range class.Days { - if day == now.Weekday() { - found = true - break + for _, class := range classes { + found := false + for _, day := range class.Days { + if day == date.Weekday() { + found = true + break + } + } + if !found { + continue } - } - if !found { - continue - } - ev := &calendar.Event{ - Summary: class.Summary, - Start: &calendar.EventDateTime{ - DateTime: fmt.Sprintf("%sT%s:00", dateStr, class.Start), - TimeZone: "US/Pacific", - }, - End: &calendar.EventDateTime{ - DateTime: fmt.Sprintf("%sT%s:00", dateStr, class.End), - TimeZone: "US/Pacific", - }, - Attendees: []*calendar.EventAttendee{}, - } - - attendees := class.Students - if len(attendees) == 0 { - attendees = students - } - - for _, student := range attendees { - ev.Attendees = append( - ev.Attendees, - &calendar.EventAttendee{ - Email: student, + ev := &calendar.Event{ + Summary: class.Summary, + Start: &calendar.EventDateTime{ + DateTime: fmt.Sprintf("%sT%s:00", dateStr, class.Start), + TimeZone: "US/Pacific", }, - ) - } + End: &calendar.EventDateTime{ + DateTime: fmt.Sprintf("%sT%s:00", dateStr, class.End), + TimeZone: "US/Pacific", + }, + Attendees: []*calendar.EventAttendee{}, + } - if class.Zoom != "" { - ev.Description = fmt.Sprintf(`Zoom: %s`, class.Zoom) - } + attendees := class.Students + if len(attendees) == 0 { + attendees = allStudents + } - _, err := srv.Events.Insert(myCal.Id, ev).Do() - if err != nil { - log.Fatal(err) + for _, student := range attendees { + ev.Attendees = append( + ev.Attendees, + &calendar.EventAttendee{ + Email: student, + }, + ) + } + + if class.Zoom != "" { + ev.Description = fmt.Sprintf(`Zoom: %s`, class.Zoom) + } + + _, err := srv.Events.Insert(myCal.Id, ev).Do() + if err != nil { + log.Fatal(err) + } } }