commit 20eb4622eb47c35cdd6fef75b7b03774c2a976bf
parent 170631b778589a9942d5ebc1628b76cb4ea612e5
Author: Russ Cox <rsc@golang.org>
Date: Thu, 18 Apr 2024 13:33:56 -0400
internal/minutes2: various fixes
Diffstat:
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/internal/minutes2/gdoc.go b/internal/minutes2/gdoc.go
@@ -5,6 +5,7 @@
package main
import (
+ "context"
"encoding/json"
"log"
"net/http"
@@ -12,18 +13,22 @@ import (
"strconv"
"strings"
+ "golang.org/x/oauth2"
+ "golang.org/x/oauth2/google"
"google.golang.org/api/docs/v1"
"google.golang.org/api/option"
- "rsc.io/oauthprompt"
)
func getClient() *http.Client {
- tokFile := "/Users/rsc/.cred/minutes2.json"
- client, err := oauthprompt.GoogleToken(tokFile, "512347153416-eehjrr21snt0av7n1opjsorg889fcged.apps.googleusercontent.com", "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", "https://www.googleapis.com/auth/documents")
+ data, err := os.ReadFile("/Users/rsc/.cred/proposal-minutes-gdoc.json")
if err != nil {
log.Fatal(err)
}
- return client
+ cfg, err := google.JWTConfigFromJSON(data, "https://www.googleapis.com/auth/documents")
+ if err != nil {
+ log.Fatal(err)
+ }
+ return cfg.Client(oauth2.NoContext)
}
type Doc struct {
@@ -46,7 +51,7 @@ func parseDoc() *Doc {
if true {
client := getClient()
- srv, err := docs.NewService(ctx, option.WithHTTPClient(client))
+ srv, err := docs.NewService(context.Background(), option.WithHTTPClient(client))
if err != nil {
log.Fatalf("Unable to retrieve Docs client: %v", err)
}
diff --git a/internal/minutes2/minutes.go b/internal/minutes2/minutes.go
@@ -142,6 +142,7 @@ func (r *Reporter) Update(doc *Doc) *Minutes {
}
sort.Strings(m.Who)
+ seen := make(map[int]bool)
Issues:
for _, di := range doc.Issues {
item := r.Items[di.Number]
@@ -149,6 +150,7 @@ Issues:
log.Printf("missing from proposal project: #%d", di.Number)
continue
}
+ seen[di.Number] = true
issue := item.Issue
status := item.FieldByName("Status")
if status == nil {
@@ -350,6 +352,18 @@ Issues:
m.Events = append(m.Events, &Event{Column: col, Issue: fmt.Sprint(di.Number), Title: title, Actions: actions})
}
+ for id, item := range r.Items {
+ status := item.FieldByName("Status")
+ if status != nil {
+ switch status.Option.Name {
+ case "Active", "Likely Accept", "Likely Decline":
+ if !seen[id] {
+ log.Printf("#%d: missing from doc", id)
+ }
+ }
+ }
+ }
+
sort.Slice(m.Events, func(i, j int) bool {
return m.Events[i].Title < m.Events[j].Title
})