Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/models/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ def fetch_data!(in_background: true)
temp_file = Tempfile.new("entry_html", encoding: "utf-8")
temp_file.write(raw_html)

md_json = `defuddle parse #{temp_file.path} -m -j`
md_html = `defuddle parse #{temp_file.path} -j`
md_json, err, status = Open3.capture3("defuddle", "parse", temp_file.path, "-m", "-j")
md_html, err, status = Open3.capture3("defuddle", "parse", temp_file.path, "-j")

# replace anything before the first { deffudle returns errors and is dumb here.
md_json = "{" + md_json.split("{", 2).last
md_html = "{" + md_html.split("{", 2).last
html_json = "{" + md_html.split("{", 2).last

self.parsed_markdown = JSON.parse(md_json)["content"]
self.parsed_html = JSON.parse(md_html)["content"]
self.parsed_html = JSON.parse(html_json)["content"]

temp_file.close
self.save
Expand Down
2 changes: 2 additions & 0 deletions db/migrate/20250613154602_create_promises.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ def change
t.string :source_type
t.string :status
t.text :text

t.text :extracted_keywords_concepts, array: true, default: []
t.text :intended_impact_and_objectives, array: true, default: []
t.text :what_it_means_for_canadians, array: true, default: []

t.text :linked_evidence_ids, array: true, default: []
t.text :relevant_departments, array: true, default: []

Expand Down
8 changes: 7 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 13 additions & 70 deletions db/seeds/canada.rb
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,18 @@
{
title: "Canada Gazette Part III: Acts of Parliament",
url: "https://gazette.gc.ca/rss/en-ls-eng.xml"
},
{
title: "Canada News Backgrounders",
url: "https://api.io.canada.ca/io-server/gc/news/en/v2?type=backgrounders&sort=publishedDate&orderBy=desc&pick=100&format=atom&atomtitle=backgrounders"
},
{
title: "Canada News Speeches",
url: "https://api.io.canada.ca/io-server/gc/news/en/v2?type=speeches&sort=publishedDate&orderBy=desc&pick=100&format=atom&atomtitle=speeches"
},
{
title: "Canada News Statements",
url: "https://api.io.canada.ca/io-server/gc/news/en/v2?type=statements&sort=publishedDate&orderBy=desc&pick=100&format=atom&atomtitle=statements"
}
]

Expand All @@ -529,76 +541,7 @@

puts "Seeding Promises..."

promise_data = {
promise_id: "LPC_20250419_OTHER_71c8234b",
action_type_classified_at: "2024-04-20T22:23:06Z",
action_type_confidence: 3,
action_type_rationale: "The promise outlines a series of strategic actions...",
background_and_context: "In the context of evolving digital infrastructure...",
bc_priority_score: 7,
bc_promise_direction: "forward",
bc_promise_rank: "high",
bc_promise_rank_rationale: "Addresses urgent gaps in policy...",
bc_ranked_at: "2024-04-21T10:12:00Z",
candidate_or_government: "LPC",
category: "Infrastructure",
concise_title: "Expand digital access",
date_issued: "2024-04-19",
description: "We promise to expand digital access across rural Canada...",
evidence_count: 5,
explanation_enrichment_model: "gpt-4",
explanation_enrichment_status: "complete",
explanation_enriched_at: "2024-04-21T12:00:00Z",
history_generated_at: "2024-04-21T14:30:00Z",
implied_action_type: "legislation",
ingested_at: "2024-04-19T09:00:00Z",
keywords_context_used: "rural access, connectivity",
keywords_enrichment_status: "complete",
keywords_enriched_at: "2024-04-21T11:45:00Z",
keywords_extracted_at: "2024-04-21T11:30:00Z",
last_enrichment_at: "2024-04-21T14:30:00Z",
last_evidence_date: "2024-04-20",
last_progress_update_at: "2024-04-22T10:00:00Z",
last_scored_at: "2024-04-22T10:05:00Z",
last_updated_at: "2024-04-22T10:10:00Z",
linking_preprocessing_done_at: "2024-04-21T15:00:00Z",
linking_processed_at: "2024-04-21T15:30:00Z",
linking_status: "linked",
migration_status_ed_at: "2024-04-21T16:00:00Z",
migration_version: "v2",
parliament_session_id: "44-1",
party: "Liberal",
party_code: "LPC",
progress_score: 4,
progress_score_1_to_5: 4,
progress_scoring_model: "v1.3",
progress_status: "in progress",
progress_summary: "Significant infrastructure projects have been launched.",
rationale_format_fixed_at: "2024-04-21T16:30:00Z",
region_code: "CA-ON",
responsible_department_lead: "Innovation, Science and Economic Development Canada",
scoring_method: "automated",
scoring_model: "gpt-4-vision",
source_document_url: "https://example.com/promise-doc",
source_type: "platform",
status: "active",
text: "We promise to expand digital access...",
extracted_keywords_concepts: [ "digital access", "rural", "infrastructure" ],
intended_impact_and_objectives: [ "Bridge the digital divide", "Support rural communities" ],
what_it_means_for_canadians: [ "Improved internet access", "Greater economic opportunity" ],
linked_evidence_ids: [ "EVID1234", "EVID5678" ],
relevant_departments: [ "ISED", "Heritage Canada" ],
commitment_history_rationale: { "2024-04" => "Budget allocated" },
commitment_history_timeline: { "2024-04" => "Bill introduced" },
key_points: { "summary" => "High priority infrastructure expansion" },
policy_areas: { "digital" => true, "rural" => true },
target_groups: { "rural_residents" => true }
}

Promise.find_or_initialize_by(promise_id: promise_data[:promise_id]).tap do |p|
p.assign_attributes(promise_data)
p.save!
end
require_relative 'canada_promises_2024'

puts "Seeding Evidences..."

Expand Down
Loading