This repository has been archived by the owner on Mar 15, 2022. It is now read-only.
forked from davecheney/pc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtodo.go
67 lines (60 loc) · 1.45 KB
/
todo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"encoding/json"
"fmt"
"os"
"sort"
"strings"
"github.com/olekukonko/tablewriter"
)
func todo(id, reviewerID int, all bool) {
f, err := os.Open(fmt.Sprintf("papercall.%d.json", id))
check(err)
var subs []*Submission
dec := json.NewDecoder(f)
err = dec.Decode(&subs)
check(err)
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"title", "format", "tags", "reason", "updated", "url"})
var rows int
sort.Slice(subs, func(i, j int) bool { return subs[j].Updated.After(subs[i].Updated) })
rev := func(a, b int) (int, int) {
if all {
a, b = b, a
}
return a, b
}
for _, s := range subs {
reason := "no rating"
if len(s.Ratings) > 0 {
sort.Slice(s.Ratings, func(i, j int) bool {
i, j = rev(i, j)
return s.Ratings[i].Updated.After(s.Ratings[j].Updated)
})
reviewerIDX := 0
for idx, reviewer := range s.Ratings {
if reviewer.Id == reviewerID {
reviewerIDX = idx
break
}
}
if s.Updated.After(s.Ratings[reviewerIDX].Updated) {
reason = "proposal updated"
} else {
continue
}
}
tags := strings.Join(s.Tags, " ")
table.Append([]string{
s.Title,
strings.SplitN(strings.ToUpper(s.Format), " ", -1)[0],
tags,
reason,
s.Updated.Format("2006-01-02 15:04:05"),
fmt.Sprintf("https://papercall.io/cfps/%d/submissions/%d", id, s.Id),
})
rows++
}
table.SetFooter([]string{"Count", fmt.Sprintf("%d", rows), "", "", "", ""})
table.Render()
}