-
Notifications
You must be signed in to change notification settings - Fork 2
Add integration for fetching voting records and parliamentary calendar in analysis workflows #2037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
e1dbb37
e143e3f
49b87e1
91a9aaa
8444124
9d992f1
b49942e
8921a77
cad0725
f52c49d
7563ee7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,324 @@ | ||||||||
| #!/usr/bin/env tsx | ||||||||
| /** | ||||||||
| * @module scripts/fetch-calendar | ||||||||
| * @description Fetch riksdag calendar events using a primary (MCP) → | ||||||||
| * fallback (web fetch + HTML parsing) chain. | ||||||||
| * | ||||||||
| * Usage: | ||||||||
| * npx tsx scripts/fetch-calendar.ts --from 2026-04-27 --tom 2026-05-27 [--org UTSK] [--akt bet] [--persist] | ||||||||
| * | ||||||||
| * Output: | ||||||||
| * analysis/data/calendar/{from}_{tom}.json — always written | ||||||||
|
||||||||
| * analysis/data/calendar/{from}_{tom}.json — always written | |
| * stdout — always written | |
| * analysis/data/calendar/{from}_{tom}.json — written only when --persist is set |
Copilot
AI
Apr 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseCalendarHtml recomputes allTimes = [...html.matchAll(timeRe)] inside the per-title loop, which makes runtime O(titles × times) and can get noticeably slow on large HTML pages. Compute the allTimes array once outside the loop and iterate with an index pointer (similar to usedDates) to keep this linear.
Copilot
AI
Apr 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the web-fallback URL construction, the --akt filter is parsed and passed to the MCP path, but it is never added to the fallback request’s query string. This means --akt has no effect whenever the script falls back to riksdagen.se HTML, leading to inconsistent results vs the MCP path. Include akt in url.searchParams (matching the server’s expected parameter name).
| if (args.org) url.searchParams.set('org', args.org); | |
| if (args.org) url.searchParams.set('org', args.org); | |
| if (args.akt) url.searchParams.set('akt', args.akt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The methodology guide now mandates
<!-- vote-not-found: {bet} -->whenstatus: "not_found". In the currentfetch-voting-records.tsimplementation,'not_found'is returned on MCP exceptions (not a confirmed "missing in voting API" case) and--persistdoes not emit an injection template for that status. Please align the documented contract with the actual script semantics/output (or adjust the script sonot_foundis only used for confirmed absence and emits a template with the appropriate annotation).