Skip to content

Replace hardcoded riksmöte '2025/26' with dynamic getCurrentRiksmote() in weekly-review, monthly-review, and propositions#639

Merged
pethers merged 2 commits intomainfrom
copilot/fix-hardcoded-riksmote-string
Feb 27, 2026
Merged

Replace hardcoded riksmöte '2025/26' with dynamic getCurrentRiksmote() in weekly-review, monthly-review, and propositions#639
pethers merged 2 commits intomainfrom
copilot/fix-hardcoded-riksmote-string

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

Three generators hardcoded '2025/26' as the rm parameter, which will break silently when the parliamentary session rolls to '2026/27' in September 2026.

Changes

  • weekly-review.ts — declare const rm = getCurrentRiksmote(today) (import already present) and use it in Step 2 typed fetchers and Step 4 speech search (4 call sites)
  • monthly-review.ts — add import { getCurrentRiksmote } from './motions.js', declare const rm = getCurrentRiksmote(today), replace 3 hardcoded values in Step 2 fetchers
  • propositions.ts — add same import, replace 1 inline hardcoded value in searchSpeeches
// Before
client.fetchCommitteeReports(50, '2025/26')
client.searchSpeeches({ rm: '2025/26', from: fromStr, to: toStr, limit: 100 })

// After
const rm = getCurrentRiksmote(today);
client.fetchCommitteeReports(50, rm)
client.searchSpeeches({ rm, from: fromStr, to: toStr, limit: 100 })

getCurrentRiksmote uses 0-based month >= 8 to determine session boundary, consistent with motions.ts, committee-reports.ts, and month-ahead.ts.

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix hardcoded riksmöte '2025/26' in weekly-review, monthly-review, and propositions generators</issue_title>
<issue_description>## 📋 Issue Type
Bug — Hardcoded parliamentary year will break at session boundary

🎯 Objective

Replace all hardcoded '2025/26' riksmöte strings in weekly-review.ts, monthly-review.ts, and propositions.ts with dynamic calculation using the existing getCurrentRiksmote() utility function.

📊 Current State

Three TypeScript generators use hardcoded '2025/26' for the rm (riksmöte) parameter when querying MCP tools. This will break when the parliamentary session changes in September 2026 to '2026/27'.

Affected files and exact lines:

scripts/news-types/weekly-review.ts (4 instances)

Already imports getCurrentRiksmote from motions.js (line 51) and correctly uses it in Step 6 (lines 904-905), but Steps 2 and 4 still have hardcoded values:

Line 827: client.fetchCommitteeReports(50, '2025/26')
Line 830: client.fetchPropositions(50, '2025/26')
Line 833: client.fetchMotions(50, '2025/26')
Line 885: client.searchSpeeches({ rm: '2025/26', from: fromStr, to: toStr, limit: 100 })

scripts/news-types/monthly-review.ts (3 instances)

Does NOT import getCurrentRiksmote at all:

Line 119: client.fetchCommitteeReports(30, '2025/26')
Line 121: client.fetchPropositions(20, '2025/26')
Line 123: client.fetchMotions(20, '2025/26')

scripts/news-types/propositions.ts (1 instance)

Does NOT import getCurrentRiksmote at all:

Line 284: client.searchSpeeches({ text: topPropTitle, rm: '2025/26', limit: 10 })

Already correct (for reference):

  • motions.ts: Defines getCurrentRiksmote() — dynamic ✅
  • committee-reports.ts: Uses dynamic calculation — dynamic ✅
  • month-ahead.ts: Uses dynamic calculation — dynamic ✅
  • breaking-news.ts: No rm parameter needed — N/A ✅
  • week-ahead.ts: No rm parameter needed — N/A ✅

🚀 Desired State

All 8 instances of '2025/26' replaced with getCurrentRiksmote() calls, ensuring the generators automatically adapt when the parliamentary session changes in September.

🔧 Implementation Approach

1. Fix weekly-review.ts (4 places)

// Already imported: import { getCurrentRiksmote } from './motions.js';
const rm = getCurrentRiksmote();

// Line 827: Replace '2025/26' with rm
client.fetchCommitteeReports(50, rm)
// Line 830: Same
client.fetchPropositions(50, rm)
// Line 833: Same
client.fetchMotions(50, rm)
// Line 885: Same
client.searchSpeeches({ rm, from: fromStr, to: toStr, limit: 100 })

2. Fix monthly-review.ts (3 places)

// Add import:
import { getCurrentRiksmote } from './motions.js';
const rm = getCurrentRiksmote();

// Lines 119, 121, 123: Replace '2025/26' with rm
client.fetchCommitteeReports(30, rm)
client.fetchPropositions(20, rm)
client.fetchMotions(20, rm)

3. Fix propositions.ts (1 place)

// Add import:
import { getCurrentRiksmote } from './motions.js';

// Line 284: Replace '2025/26' with getCurrentRiksmote()
client.searchSpeeches({ text: topPropTitle, rm: getCurrentRiksmote(), limit: 10 })

🤖 Recommended Agent

code-quality-engineer — Simple find-and-replace with import addition

✅ Acceptance Criteria

  • weekly-review.ts — all 4 hardcoded '2025/26' replaced with getCurrentRiksmote()
  • monthly-review.ts — import added + all 3 hardcoded values replaced
  • propositions.ts — import added + 1 hardcoded value replaced
  • Zero '2025/26' strings in any news-type .ts file (excluding comments)
  • All existing tests pass (npx vitest run)
  • No new test failures introduced

📚 References

  • Dynamic utility: scripts/news-types/motions.ts:234-240getCurrentRiksmote() function
  • Correct usage pattern: scripts/news-types/weekly-review.ts:904-905 — already uses dynamic
  • Related memory: riksmöte calculation uses 0-based month (getMonth() >= 8)
    </issue_description>

<agent_instructions>Replace all 8 hardcoded '2025/26' strings with dynamic getCurrentRiksmote() calls in weekly-review.ts (4 places), monthly-review.ts (3 places, add import), and propositions.ts (1 place, add import). The getCurrentRiksmote function is defined in scripts/news-types/motions.ts. See the correct usage pattern at weekly-review.ts lines 904-905. Run npx vitest run to verify all tests pass.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…d propositions

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix hardcoded riksmöte year in review generators Replace hardcoded riksmöte '2025/26' with dynamic getCurrentRiksmote() in weekly-review, monthly-review, and propositions Feb 27, 2026
@pethers pethers requested a review from Copilot February 27, 2026 17:02
@github-actions github-actions bot added refactor Code refactoring size-s Small change (10-50 lines) labels Feb 27, 2026
@github-actions
Copy link
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request replaces hardcoded riksmöte (parliamentary session) strings '2025/26' with dynamic calculation using the getCurrentRiksmote() utility function across three news generator modules. This change prevents silent failures when the parliamentary session changes in September 2026 to '2026/27'.

Changes:

  • Replace 8 instances of hardcoded '2025/26' with dynamic getCurrentRiksmote() calls
  • Add missing imports to monthly-review.ts and propositions.ts
  • Ensure consistent session calculation across all news-type generators

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
scripts/news-types/weekly-review.ts Declares const rm = getCurrentRiksmote(today) at line 825 and uses it in 4 call sites (3 in Step 2 typed fetchers, 1 in Step 4 speech search). Import already existed.
scripts/news-types/monthly-review.ts Adds getCurrentRiksmote import from ./motions.js, declares const rm = getCurrentRiksmote(today) at line 119, and replaces 3 hardcoded values in Step 2 fetchers.
scripts/news-types/propositions.ts Adds getCurrentRiksmote import from ./motions.js and replaces 1 inline hardcoded value with getCurrentRiksmote() call in Step 4 speech search.

@pethers pethers marked this pull request as ready for review February 27, 2026 17:23
@pethers pethers merged commit 58bd531 into main Feb 27, 2026
21 checks passed
@pethers pethers deleted the copilot/fix-hardcoded-riksmote-string branch February 27, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring size-s Small change (10-50 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix hardcoded riksmöte '2025/26' in weekly-review, monthly-review, and propositions generators

3 participants