forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyze-recent-weeks.sh
More file actions
executable file
·219 lines (174 loc) · 6.34 KB
/
analyze-recent-weeks.sh
File metadata and controls
executable file
·219 lines (174 loc) · 6.34 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/bin/bash
# GitHub Issues Analyzer for Recent Weeks
# Analyzes Dec 15-21 (Week 50) and Dec 22-26 (Week 51)
# Usage: ./scripts/analyze-recent-weeks.sh
set -euo pipefail
REPO="sst/opencode"
GITHUB_API="https://api.github.com/repos"
# Start from Dec 15
START_DATE="2025-12-15T00:00:00Z"
echo "Analyzing GitHub issues from Dec 15 onwards..."
echo "Start date: $START_DATE"
echo ""
# Create temp file
TEMP_FILE=$(mktemp)
trap "rm -f $TEMP_FILE" EXIT
echo "[]" > "$TEMP_FILE"
# Fetch all issues from Dec 15 onwards (paginate through results)
for page in {1..5}; do
echo " Fetching page $page..."
PAGE_DATA=$(curl -s "${GITHUB_API}/${REPO}/issues?state=all&sort=created&direction=desc&per_page=100&page=${page}")
# Check if we got any results
COUNT=$(echo "$PAGE_DATA" | jq 'length')
if [ "$COUNT" -eq 0 ]; then
echo " No more results on page $page"
break
fi
# Filter issues from Dec 15 onwards
FILTERED=$(echo "$PAGE_DATA" | jq "[.[] | select(.created_at >= \"${START_DATE}\")]")
FILTERED_COUNT=$(echo "$FILTERED" | jq 'length')
echo " Found $FILTERED_COUNT issues from Dec 15 onwards on page $page"
# Append to temp file
CURRENT=$(cat "$TEMP_FILE")
MERGED=$(echo "$CURRENT" "$FILTERED" | jq -s '.[0] + .[1]')
echo "$MERGED" > "$TEMP_FILE"
# If we've started getting old data, we can stop
OLDEST=$(echo "$PAGE_DATA" | jq -r '.[-1].created_at')
if [[ "$OLDEST" < "$START_DATE" ]]; then
echo " Reached data older than Dec 15, stopping"
break
fi
done
echo ""
# Create Python analysis script
PYTHON_SCRIPT=$(mktemp)
trap "rm -f $PYTHON_SCRIPT $TEMP_FILE" EXIT
cat > "$PYTHON_SCRIPT" << 'EOF'
import json
import sys
from datetime import datetime
from collections import defaultdict
# Read the issues data from file
with open(sys.argv[1], 'r') as f:
data = json.load(f)
if not data:
print("No issues found from Dec 15 onwards")
sys.exit(0)
print(f"Analyzing {len(data)} issues...\n")
# Categorize and group by week
issues_by_week = defaultdict(lambda: defaultdict(int))
week_totals = defaultdict(int)
week_order = []
# Response tracking
response_by_week = defaultdict(lambda: {
'total': 0,
'with_response': 0,
'no_response': 0
})
def get_week_label(date_str):
"""Convert date to week label"""
date = datetime.fromisoformat(date_str.replace('Z', '+00:00')).replace(tzinfo=None)
# Manual week grouping for clarity
if date >= datetime(2025, 12, 22):
return "Week 51: Dec 22-26"
elif date >= datetime(2025, 12, 15):
return "Week 50: Dec 15-21"
else:
return "Earlier"
def categorize_issue(item):
"""Categorize an issue"""
if item.get('pull_request'):
return "PR"
labels = [label['name'] for label in item.get('labels', [])]
title = item['title'].lower()
if 'discussion' in labels:
return "Feature Request"
elif 'help-wanted' in labels:
return "Help Question"
elif 'bug' in labels:
return "Bug Report"
elif any(x in title for x in ['[feature]', 'feature request', '[feat]']):
return "Feature Request"
elif title.endswith('?') and 'bug' not in title:
return "Help Question"
else:
return "Other"
# Process each issue
for item in data:
week_label = get_week_label(item['created_at'])
if week_label not in week_order:
week_order.append(week_label)
category = categorize_issue(item)
# Check if it's an actual issue (not PR)
if not item.get('pull_request'):
response_by_week[week_label]['total'] += 1
if item['comments'] > 0:
response_by_week[week_label]['with_response'] += 1
else:
response_by_week[week_label]['no_response'] += 1
issues_by_week[week_label][category] += 1
week_totals[week_label] += 1
# Sort weeks (most recent first)
week_order = sorted([w for w in week_order if w != "Earlier"], reverse=True)
# Print results
print("="*80)
print("GITHUB ISSUES BREAKDOWN - RECENT WEEKS")
print("="*80 + "\n")
for week in week_order:
print(f"{week}: {week_totals[week]} total")
for category in sorted(issues_by_week[week].keys()):
count = issues_by_week[week][category]
print(f" • {category}: {count}")
print()
print("---")
total = sum(week_totals[w] for w in week_order)
print(f"TOTAL: {total} issues/PRs\n")
print("OVERALL SUMMARY:")
all_counts = defaultdict(int)
for week in week_order:
for category, count in issues_by_week[week].items():
all_counts[category] += count
for category in sorted(all_counts.keys(), key=lambda x: -all_counts[x]):
count = all_counts[category]
pct = (count / total) * 100
print(f" • {category}: {count} ({pct:.1f}%)")
# Response rates
print("\n" + "="*80)
print("ISSUE RESPONSE RATES")
print("="*80 + "\n")
for week in week_order:
data = response_by_week[week]
if data['total'] > 0:
rate = (data['with_response'] / data['total'] * 100)
print(f"{week}:")
print(f" Total issues: {data['total']}")
print(f" With response: {data['with_response']} ({rate:.1f}%)")
print(f" No response: {data['no_response']}")
print()
# Week over week comparison
print("="*80)
print("WEEK-OVER-WEEK COMPARISON")
print("="*80 + "\n")
if len(week_order) >= 2:
w1 = week_order[0] # Most recent
w2 = week_order[1] # Previous
vol_change = week_totals[w1] - week_totals[w2]
vol_pct = (vol_change / week_totals[w2] * 100) if week_totals[w2] > 0 else 0
print(f"Volume Change: {week_totals[w2]} → {week_totals[w1]} ({vol_pct:+.1f}%)")
print()
print("Category Changes:")
for category in sorted(all_counts.keys()):
old_val = issues_by_week[w2].get(category, 0)
new_val = issues_by_week[w1].get(category, 0)
change = new_val - old_val
direction = "↑" if change > 0 else "↓" if change < 0 else "→"
print(f" {category:18s}: {old_val:3d} → {new_val:3d} {direction} {abs(change)}")
print()
if response_by_week[w1]['total'] > 0 and response_by_week[w2]['total'] > 0:
r1 = (response_by_week[w1]['with_response'] / response_by_week[w1]['total'] * 100)
r2 = (response_by_week[w2]['with_response'] / response_by_week[w2]['total'] * 100)
print(f"Response Rate: {r2:.1f}% → {r1:.1f}% ({r1-r2:+.1f}pp)")
print("\n" + "="*80 + "\n")
EOF
# Run the analysis
python3 "$PYTHON_SCRIPT" "$TEMP_FILE"