Migrate SRS to Cloudflare Worker: D1 state, email digest, review issues, live charts

This commit is contained in:
Prad Nukala
2026-08-24 19:11:07 -04:00
parent 6be5d55366
commit 7213cc1c8a
40 changed files with 2933 additions and 2132 deletions
-6
View File
@@ -1,6 +0,0 @@
{
"schemaVersion": 1,
"label": "gate pass rate",
"message": "no gates yet",
"color": "lightgrey"
}
-26
View File
@@ -1,26 +0,0 @@
{
"2026-08-17": 3,
"2026-08-18": 4,
"2026-08-24": 5,
"2026-08-25": 6,
"2026-08-26": 7,
"2026-08-27": 8,
"2026-08-28": 9,
"2026-08-31": 10,
"2026-09-01": 11,
"2026-09-02": 12,
"2026-09-03": 13,
"2026-09-04": 14,
"2026-09-07": 15,
"2026-09-08": 16,
"2026-09-09": 17,
"2026-09-10": 18,
"2026-09-11": 19,
"2026-09-14": 20,
"2026-09-15": 21,
"2026-09-16": 22,
"2026-09-17": 23,
"2026-09-18": 24,
"2026-09-21": 25,
"2026-09-22": 26
}
-563
View File
@@ -1,563 +0,0 @@
{
"problems": {
"1": {
"issue": 29,
"topic": 3,
"difficulty": "easy",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"4": {
"issue": 66,
"topic": 7,
"difficulty": "hard",
"set": "deferred",
"stage": "new",
"next_review": "2026-09-29",
"defer_until": "2026-09-29",
"history": []
},
"11": {
"issue": 44,
"topic": 5,
"difficulty": "medium",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"15": {
"issue": 43,
"topic": 5,
"difficulty": "medium",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"33": {
"issue": 60,
"topic": 7,
"difficulty": "medium",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"42": {
"issue": 49,
"topic": 5,
"difficulty": "hard",
"set": "deferred",
"stage": "new",
"next_review": "2026-09-28",
"defer_until": "2026-09-28",
"history": []
},
"49": {
"issue": 30,
"topic": 3,
"difficulty": "medium",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"52": {
"issue": 156,
"topic": 22,
"difficulty": "hard",
"set": "deferred",
"stage": "new",
"next_review": "2026-10-03",
"defer_until": "2026-10-03",
"history": []
},
"72": {
"issue": 171,
"topic": 24,
"difficulty": "medium",
"set": "deferred",
"stage": "new",
"next_review": "2026-10-03",
"defer_until": "2026-10-03",
"history": []
},
"76": {
"issue": 57,
"topic": 6,
"difficulty": "hard",
"set": "deferred",
"stage": "new",
"next_review": "2026-09-28",
"defer_until": "2026-09-28",
"history": []
},
"84": {
"issue": 76,
"topic": 9,
"difficulty": "hard",
"set": "deferred",
"stage": "new",
"next_review": "2026-09-30",
"defer_until": "2026-09-30",
"history": []
},
"97": {
"issue": 172,
"topic": 24,
"difficulty": "medium",
"set": "deferred",
"stage": "new",
"next_review": "2026-10-04",
"defer_until": "2026-10-04",
"history": []
},
"121": {
"issue": 50,
"topic": 6,
"difficulty": "easy",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"124": {
"issue": 105,
"topic": 13,
"difficulty": "hard",
"set": "deferred",
"stage": "new",
"next_review": "2026-09-30",
"defer_until": "2026-09-30",
"history": []
},
"125": {
"issue": 41,
"topic": 5,
"difficulty": "easy",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"167": {
"issue": 42,
"topic": 5,
"difficulty": "medium",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"212": {
"issue": 129,
"topic": 17,
"difficulty": "hard",
"set": "deferred",
"stage": "new",
"next_review": "2026-10-02",
"defer_until": "2026-10-02",
"history": []
},
"217": {
"issue": 27,
"topic": 3,
"difficulty": "easy",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"221": {
"issue": 173,
"topic": 24,
"difficulty": "medium",
"set": "deferred",
"stage": "new",
"next_review": "2026-10-04",
"defer_until": "2026-10-04",
"history": []
},
"224": {
"issue": 71,
"topic": 8,
"difficulty": "hard",
"set": "deferred",
"stage": "new",
"next_review": "2026-09-29",
"defer_until": "2026-09-29",
"history": []
},
"238": {
"issue": 37,
"topic": 4,
"difficulty": "medium",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"242": {
"issue": 28,
"topic": 3,
"difficulty": "easy",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"269": {
"issue": 145,
"topic": 20,
"difficulty": "hard",
"set": "deferred",
"stage": "new",
"next_review": "2026-10-02",
"defer_until": "2026-10-02",
"history": []
},
"295": {
"issue": 125,
"topic": 16,
"difficulty": "hard",
"set": "deferred",
"stage": "new",
"next_review": "2026-10-01",
"defer_until": "2026-10-01",
"history": []
},
"303": {
"issue": 36,
"topic": 4,
"difficulty": "easy",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"347": {
"issue": 31,
"topic": 3,
"difficulty": "medium",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"383": {
"issue": 32,
"topic": 3,
"difficulty": "easy",
"set": "optional",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"392": {
"issue": 45,
"topic": 5,
"difficulty": "easy",
"set": "optional",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"502": {
"issue": 126,
"topic": 16,
"difficulty": "hard",
"set": "deferred",
"stage": "new",
"next_review": "2026-10-01",
"defer_until": "2026-10-01",
"history": []
},
"560": {
"issue": 38,
"topic": 4,
"difficulty": "medium",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"704": {
"issue": 58,
"topic": 7,
"difficulty": "easy",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"875": {
"issue": 59,
"topic": 7,
"difficulty": "medium",
"set": "core",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
},
"977": {
"issue": 46,
"topic": 5,
"difficulty": "easy",
"set": "optional",
"solved_on": "2026-08-24",
"stage": "+2",
"next_review": "2026-08-26",
"history": [
{
"date": "2026-08-24",
"kind": "first",
"result": "pass"
}
]
}
},
"topics": {
"3": {
"misses": 0,
"boost": false
},
"4": {
"misses": 0,
"boost": false
},
"5": {
"misses": 0,
"boost": false
},
"6": {
"misses": 0,
"boost": false
},
"7": {
"misses": 0,
"boost": false
},
"8": {
"misses": 0,
"boost": false
},
"9": {
"misses": 0,
"boost": false
},
"10": {
"misses": 0,
"boost": false
},
"11": {
"misses": 0,
"boost": false
},
"12": {
"misses": 0,
"boost": false
},
"13": {
"misses": 0,
"boost": false
},
"14": {
"misses": 0,
"boost": false
},
"15": {
"misses": 0,
"boost": false
},
"16": {
"misses": 0,
"boost": false
},
"17": {
"misses": 0,
"boost": false
},
"18": {
"misses": 0,
"boost": false
},
"19": {
"misses": 0,
"boost": false
},
"20": {
"misses": 0,
"boost": false
},
"21": {
"misses": 0,
"boost": false
},
"22": {
"misses": 0,
"boost": false
},
"23": {
"misses": 0,
"boost": false
},
"24": {
"misses": 0,
"boost": false
},
"25": {
"misses": 0,
"boost": false
},
"26": {
"misses": 0,
"boost": false
}
},
"drill_pool_used": [],
"gates": [
{
"week": 2,
"issue": 208,
"date": "2026-08-24",
"problems": [
189,
209,
162,
71,
496
],
"fallbacks": [],
"results": {}
}
]
}
-67
View File
@@ -1,67 +0,0 @@
name: Gate
on:
schedule:
- cron: "0 12 * * 6" # Saturday 8 AM ET — create this week's gate
workflow_dispatch:
issues:
types: [closed] # grade a gate when it closes
permissions:
contents: write
issues: write
# Shared with srs-scheduler / srs-logger / srs-setup: never race on srs.json.
concurrency:
group: srs-state
cancel-in-progress: false
jobs:
create:
# Trigger A: the only issue-creating workflow in the SRS. The script
# no-ops when this week's gate already exists.
if: github.event_name != 'issues'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun scripts/srs-gate.ts create
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit state
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .github/srs
git diff --cached --quiet && { echo "no state change"; exit 0; }
git commit -m "srs: create weekly gate [skip ci]"
for i in 1 2 3; do git push && exit 0; git pull --rebase; done
git push
close:
# Trigger B: grade, log, boost, badge.
if: >-
github.event_name == 'issues' &&
contains(github.event.issue.labels.*.name, 'gate')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun scripts/srs-gate.ts close
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit state
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .github/srs docs/gate-log.md
git diff --cached --quiet && { echo "no state change"; exit 0; }
git commit -m "srs: grade gate #${{ github.event.issue.number }} [skip ci]"
for i in 1 2 3; do git push && exit 0; git pull --rebase; done
git push
-43
View File
@@ -1,43 +0,0 @@
name: SRS Logger
on:
issue_comment:
types: [created]
permissions:
contents: write
issues: write
# Shared with srs-scheduler / gate / srs-setup: never race on srs.json.
concurrency:
group: srs-state
cancel-in-progress: false
jobs:
log:
# Owner-only, and only on the daily brief or a gate issue. Put every
# /done line in ONE comment — queued duplicate runs may be superseded.
if: >-
github.event.comment.user.login == github.repository_owner &&
(github.event.issue.title == '📋 Today' ||
contains(github.event.issue.labels.*.name, 'gate'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun scripts/srs-logger.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PROJECT_PAT: ${{ secrets.PROJECT_PAT }}
- name: Commit state
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .github/srs
git diff --cached --quiet && { echo "no state change"; exit 0; }
git commit -m "srs: log results from #${{ github.event.issue.number }} [skip ci]"
for i in 1 2 3; do git push && exit 0; git pull --rebase; done
git push
-30
View File
@@ -1,30 +0,0 @@
name: SRS Scheduler
on:
schedule:
- cron: "0 10 * * *" # 6 AM ET — before the day starts
workflow_dispatch:
permissions:
contents: read
issues: write
# Shared with srs-logger / gate / srs-setup: never race on srs.json.
concurrency:
group: srs-state
cancel-in-progress: false
jobs:
brief:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
# Stateless: reads srs.json + schedule.json, rewrites the pinned
# 📋 Today issue, mirrors Target Date. Commits nothing.
- run: bun scripts/srs-scheduler.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PROJECT_PAT: ${{ secrets.PROJECT_PAT }}
-29
View File
@@ -1,29 +0,0 @@
name: SRS Setup
on:
workflow_dispatch:
permissions:
contents: read
issues: read
# Shared with the other SRS workflows: never race on srs.json.
concurrency:
group: srs-state
cancel-in-progress: false
jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
# Verifies PROJECT_PAT against the user project, creates the SRS
# single-select fields when missing, and re-mirrors every laddered
# problem's Target Date / SRS Stage / First Attempt. Idempotent.
- run: bun scripts/srs-setup.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PROJECT_PAT: ${{ secrets.PROJECT_PAT }}