Add party decision flow database view for legislative effectiveness analysis#7928
Add party decision flow database view for legislative effectiveness analysis#7928
Conversation
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
…x creation Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR adds a new database view view_riksdagen_party_decision_flow that aggregates Swedish parliamentary proposal decisions by party, enabling comprehensive analysis of party-level legislative effectiveness. The view supports the Citizen Intelligence Agency's political analysis capabilities by providing metrics on how different parties perform in getting their proposals approved or rejected across various committees and time periods.
Key Changes:
- Created
view_riksdagen_party_decision_flowaggregating proposal decisions by party, committee, decision type, and temporal dimensions - Added 4 performance indexes on base tables (document_proposal_data, document_data, document_person_reference_da_0)
- Comprehensive documentation with 7 SQL query examples covering party scorecards, coalition analysis, and committee effectiveness tracking
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| service.data.impl/src/main/resources/db-changelog.xml | Includes new v1.35 changelog in master changelog sequence |
| service.data.impl/src/main/resources/db-changelog-1.35.xml | Defines new party decision flow view with pre/post-flight validation, view creation, and performance indexes |
| DATABASE_VIEW_INTELLIGENCE_CATALOG.md | Adds comprehensive documentation for the new view including purpose, schema, Swedish terminology, 7 example queries, performance characteristics, risk rules mapping, and intelligence applications |
| Party Decision Flow View - Database Changelog v1.35 | ||
| Author: Political Analyst & Intelligence Operative | ||
| Date: 2025-11-22 | ||
| GitHub Issue: Hack23/cia#[issue-number] |
There was a problem hiding this comment.
The GitHub issue reference contains a placeholder instead of the actual issue number. Based on the PR description, this should be:
GitHub Issue: Hack23/cia#7887(or #7918 as mentioned in the agent tips at the bottom of the PR)
| GitHub Issue: Hack23/cia#[issue-number] | |
| GitHub Issue: Hack23/cia#7887 |
There was a problem hiding this comment.
Fixed in commit ac98ad7. Updated GitHub issue reference to Hack23/cia#7887.
| AND dpd.committee IS NOT NULL | ||
| AND dd.made_public_date IS NOT NULL | ||
| AND LENGTH(dpd.chamber) >= 6 -- Minimum valid decision text length | ||
| AND LENGTH(dpd.chamber) <= 100 -- Reasonable max length |
There was a problem hiding this comment.
The maximum length constraint for dpd.chamber (100 characters) differs from the business logic in DecisionDataFactoryImpl.java which uses 29 characters as the maximum valid length for chamber text (based on "återförvisning till utskottet").
Consider aligning this with the application code:
AND LENGTH(dpd.chamber) <= 29 -- Matches DecisionDataFactoryImpl.CHAMBER_MAX_LENGTHThis ensures the view filters data consistently with how the application layer processes proposals.
| AND LENGTH(dpd.chamber) <= 100 -- Reasonable max length | |
| AND LENGTH(dpd.chamber) <= 29 -- Matches DecisionDataFactoryImpl.CHAMBER_MAX_LENGTH |
There was a problem hiding this comment.
Fixed in commit ac98ad7. Changed chamber maximum length from 100 to 29 characters to align with DecisionDataFactoryImpl.CHAMBER_MAX_LENGTH. Added comments referencing the source constant for clarity.
|
@copilot apply changes based on the comments in this thread Missing full-schema.sql as part of https://github.com/Hack23/cia/blob/master/service.data.impl/README-SCHEMA-MAINTENANCE.md , copilot have access to postgres to test changelog https://github.com/Hack23/cia/blob/master/.github/workflows/copilot-setup-steps.yml |
…h DecisionDataFactoryImpl, regenerate full_schema.sql Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Changes applied in commit ac98ad7: Review comments addressed:
Schema maintenance completed:
All changes tested with PostgreSQL and build validates successfully. |
| - 📊 **Committee Influence Maps** - Which parties control which committees | ||
| - 📈 **Temporal Effectiveness Trends** - Is party legislative power growing or declining? | ||
|
|
||
| **Data Flow:** See [Intelligence Data Flow Map](INTELLIGENCE_DATA_FLOW.md#decision-flow-views) for complete data pipeline. |
There was a problem hiding this comment.
The documentation references a non-existent section in INTELLIGENCE_DATA_FLOW.md. The link points to #decision-flow-views which does not exist in the file.
Current reference (line 2960):
**Data Flow:** See [Intelligence Data Flow Map](INTELLIGENCE_DATA_FLOW.md#decision-flow-views) for complete data pipeline.Issue: The INTELLIGENCE_DATA_FLOW.md file (414 lines total) does not contain a "decision-flow-views" section or anchor.
Recommendation:
Either:
- Remove the specific anchor and use a general reference:
[Intelligence Data Flow Map](INTELLIGENCE_DATA_FLOW.md) - Add a new "Decision Flow Views" section to INTELLIGENCE_DATA_FLOW.md to document this new view category
- Reference an existing relevant section like
#party-views
| **Data Flow:** See [Intelligence Data Flow Map](INTELLIGENCE_DATA_FLOW.md#decision-flow-views) for complete data pipeline. | |
| **Data Flow:** See [Intelligence Data Flow Map](INTELLIGENCE_DATA_FLOW.md) for complete data pipeline. |
There was a problem hiding this comment.
Fixed in commit 293bb33. Updated the broken anchor from #decision-flow-views (which doesn't exist) to #party-views (existing section in INTELLIGENCE_DATA_FLOW.md line 196). The link now correctly references the Party Views section.
|
@copilot apply changes based on the comments in this thread |
…r from non-existent #decision-flow-views to #party-views Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Changes applied in commit 293bb33. Fixed the broken documentation link in DATABASE_VIEW_INTELLIGENCE_CATALOG.md - updated anchor from non-existent |
|



Description
Creates
view_riksdagen_party_decision_flowto aggregate proposal decisions by party, committee, and time period. Enables party-level legislative effectiveness analysis and coalition dynamics assessment.Key capabilities:
Files Created:
db-changelog-1.35.xml- Liquibase changelog with view definition and 4 performance indexesDATABASE_VIEW_INTELLIGENCE_CATALOG.mdwith 7 SQL examplesFiles Modified:
db-changelog.xml- Added v1.35 include referencefull_schema.sql- Regenerated with new view and indexes (13,020 lines)DATABASE_VIEW_INTELLIGENCE_CATALOG.md- Fixed broken documentation link to INTELLIGENCE_DATA_FLOW.mdType of Change
Primary Changes
Political Analysis
Technical Changes
Impact Analysis
Political Analysis Impact
Technical Impact
Testing
Build validation:
mvn clean compile -pl service.data.impl -DskipTests # BUILD SUCCESSDatabase validation:
Code review: 3 issues addressed
Documentation
Added to DATABASE_VIEW_INTELLIGENCE_CATALOG.md:
Related Issues
Fixes #7887
Checklist
Additional Notes
View schema:
Join path:
Intelligence applications:
Review feedback addressed:
Security Considerations
Party-level aggregation only—no personal data. Uses public Riksdag API data.
Release Notes
v1.35 - Party Decision Flow View
Added
view_riksdagen_party_decision_flowfor party-level proposal decision analysis. Aggregates by party, committee, decision type, and time period with Swedish Riksdag terminology support (bifall, avslag, återförvisning). Enables legislative effectiveness tracking, coalition alignment analysis, and committee influence assessment. Includes 4 performance indexes and comprehensive documentation with 7 SQL query examples.Original prompt
This section details on the original issue you should resolve
<issue_title>Create Party Decision Flow View from DOCUMENT_PROPOSAL_DATA</issue_title>
<issue_description>## 🎯 Objective
Create a database view that aggregates decision flow data by political party from DOCUMENT_PROPOSAL_DATA, enabling analysis of party-level proposal success rates, decision patterns, and legislative effectiveness.
📋 Background
The current
DecisionDataFactoryImplprocesses individual proposal decisions, but lacks aggregated party-level intelligence. This view will support:Context from Documentation:
📊 Current State
✅ Acceptance Criteria
view_riksdagen_party_decision_flowdatabase viewdb-changelog-1.35.xml🛠️ Implementation Guidance
Files to Create/Modify:
service.data.impl/src/main/resources/db-changelog-1.35.xml(NEW)DATABASE_VIEW_INTELLIGENCE_CATALOG.md- Add documentationApproach:
document_proposal_datatable schemadocument_status_containeranddocument_datafor party informationSample Query for Testing:
🤖 Recommended Agent
Agent: @hack23-intelligence-operative
Rationale: This issue requires deep understanding of Swedish parliamentary decision processes, OSINT data analysis methodologies, and political intelligence product development.
For implementation, the Intelligence Operative will:
📚 Related Documentation
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.