-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
poll-results.sh
executable file
·43 lines (35 loc) · 932 Bytes
/
poll-results.sh
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
#!/bin/sh
set -euo pipefail
F="$(mktemp)"
HAS_XSV="$(command -v xsv)"
# HAS_XSV=""
if [ ! "$(command -v gh)" ]; then
echo "This script requires the GitHub CLI."
echo "https://cli.github.com"
exit 1
fi
if [ "$HAS_XSV" ]; then
echo 'votes,feature,"issue url"' >> "$F"
else
echo "votes \tfeature \tissue url" >> "$F"
fi
gh issue list \
--repo="robjtede/actix-web-lab" \
--limit=999 \
--search="is:issue is:open label:poll sort:reactions-+1-desc" \
--json="title,url,reactionGroups" \
--jq '
.[]
| {
title,
url,
votes: ((.reactionGroups[]? | select(.content == "THUMBS_UP") | .users.totalCount) // 0)
}
| "\(.votes),\"\(.title)\",\(.url)"
' \
| sed -E 's/(.*)\[poll\] (.*)/\1\2/' >> "$F"
if [ "$HAS_XSV" ]; then
cat "$F" | xsv table
else
cat "$F" | awk -F "\"*,\"*" '{ print $1 "\t" $2 "\t" $3 }'
fi