Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
…out anomaly view Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com> Agent-Logs-Url: https://github.com/Hack23/cia/sessions/31d8f482-8daf-4274-b238-201e330cc806
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com> Agent-Logs-Url: https://github.com/Hack23/cia/sessions/31d8f482-8daf-4274-b238-201e330cc806
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com> Agent-Logs-Url: https://github.com/Hack23/cia/sessions/a06ef42c-7902-4eef-b64d-f240315bfbc9
|
There was a problem hiding this comment.
Pull request overview
This PR updates the database layer (Liquibase + regenerated full_schema.sql) to fix systemic filter/enum/case-sensitivity issues that caused many analytics views to return empty/NULL/zeroed results, and introduces performance improvements via new materialized sub-views.
Changes:
- Added Liquibase changelogs
1.77and1.78and wired them into the rootdb-changelog.xml. - Regenerated
full_schema.sqlto reflect applied changesets, including corrected view definitions and new materialized views/indexes. - Updated multiple view definitions to use correct data conventions (e.g., vote casing, rule_group/status/document_type filters) and removed a Cartesian-join timeout source.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| service.data.impl/src/main/resources/full_schema.sql | Regenerated schema dump reflecting updated/added analytical views, matviews, and databasechangelog entries through 1.78. |
| service.data.impl/src/main/resources/db-changelog.xml | Includes the new 1.77 and 1.78 Liquibase changelog files in sequence. |
| service.data.impl/src/main/resources/db-changelog-1.77.xml | Adds view rebuilds/fixes for party transition/defection/switcher views and eliminates anomaly-pattern Cartesian join timeout. |
| service.data.impl/src/main/resources/db-changelog-1.78.xml | Fixes vote casing, risk summary rule_group mapping, party performance metrics filters, and recreates dependent views after CASCADE drops. |
| ELSE false | ||
| END AS is_post_election_period | ||
| FROM windowed_statistics ws | ||
| ORDER BY party, election_cycle_id, cycle_year, semester;; |
There was a problem hiding this comment.
This CREATE VIEW statement ends with ;;. To avoid Liquibase executing an empty SQL statement after splitting, keep only a single trailing semicolon.
| ORDER BY party, election_cycle_id, cycle_year, semester;; | |
| ORDER BY party, election_cycle_id, cycle_year, semester; |
| ELSE false | ||
| END AS is_election_cycle_end | ||
| FROM windowed_statistics ws | ||
| ORDER BY party, election_cycle_id, cycle_year, semester;; |
There was a problem hiding this comment.
This CREATE VIEW statement ends with ;;. Liquibase can treat this as an extra empty statement; please remove the extra semicolon and keep just one terminator.
| ORDER BY party, election_cycle_id, cycle_year, semester;; | |
| ORDER BY party, election_cycle_id, cycle_year, semester; |
| END AS performance_trend, | ||
| round((((performance_score * 0.4) + (party_win_rate * 0.3)) + (party_participation_rate * 0.3)), 2) AS discipline_score, | ||
| round((((rank_by_performance)::numeric / (NULLIF(cycle_party_count, 0))::numeric) * (100)::numeric), 2) AS competitiveness_index | ||
| FROM windowed w;; |
There was a problem hiding this comment.
This SQL ends with a double semicolon (;;). Liquibase may split statements on semicolons and attempt to execute an empty statement, which can break migrations depending on configuration/driver. Remove the extra semicolon so the CREATE VIEW ends with a single ;.
| FROM windowed w;; | |
| FROM windowed w; |



Description
Fixes 4 systemic root causes that left 32 advanced analytical views returning zero/NULL data despite underlying tables having millions of rows. Applied 22 new Liquibase changesets (1.76–1.78), verified application startup, and regenerated
full_schema.sqlviapg_dump.Root causes:
'Ja') but data is uppercase ('JA')absence_rate=0,rebel_rate=NULLeverywhereview_risk_score_evolution→ 6 downstream viewsfull_schema.sqlstale: 1.76-011 fix marked EXECUTED but view definition revertedview_politician_risk_summary→ 3 downstream viewsrule_groupfilters use non-existent enums ('ABSENTEEISM') instead of actual DRL values ('Behavior','Assignments','Experience','Party','Role')view_politician_risk_summarystatus='active'(actual: Swedish strings),rv.status='ACTIVE'(actual:MINOR/MAJOR/CRITICAL),document_type='Motion'(actual:'mot')active_members=0,motions_count=0for all partiesview_party_performance_metrics→ 3 downstream viewsExample fix (vote case sensitivity):
Changesets applied:
assignment_dataorg_codes, defector/switcher analysis, anomaly pattern Cartesian join eliminationVerified: Application starts (Jetty port 28443, healthcheck OK). Schema regenerated with
pg_dumpper maintenance guide.Type of Change
Primary Changes
Political Analysis
Technical Changes
Impact Analysis
Political Analysis Impact
Technical Impact
Testing
All 22 changesets validated via Liquibase update, application startup verified (healthcheck OK), schema regenerated and verified.
Documentation
Rule group mapping documented inline in SQL comments for backward-compatible column aliasing.
Screenshots
N/A — database view fixes, no UI changes.
Related Issues
Checklist
Additional Notes
Data sources used for validation:
vote_data.vote: JA(2.08M), FRÅNVARANDE(742K), NEJ(677K), AVSTÅR(203K)rule_violation: 2,301 rows,rule_group∈ {Behavior, Assignments, Experience, Party, Role, Attribute, Structure}rule_violation.status∈ {MINOR, MAJOR, CRITICAL} — not ACTIVEdocument_data.document_type∈ {mot, bet, prop, kammakt} — not Motion/Propositionperson_data.status: Swedish strings — not active/inactiveSecurity Considerations
Release Notes
Fixed 32 advanced analytical views returning empty/zero data due to case-sensitivity bugs in vote comparisons, incorrect enum values for rule violations and document types, wrong person status filters, and stale schema definitions. Eliminated timeout in election cycle anomaly pattern view. Applied 22 Liquibase changesets (1.76–1.78) and regenerated full_schema.sql.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.