Add Canadian parliamentary appearance tracker (R) with README and Twitter handles template - #5
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 34ad2fb2c9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| doc |> | ||
| html_elements(xpath = "//a[contains(@href, '/noticeofmeeting/')]") |> | ||
| html_attr("href") |> |
There was a problem hiding this comment.
Use a server-rendered source for Senate notices
The current https://sencanada.ca/en/committees/allmeetings/ page is client-rendered: its raw HTML stops at the “Schedule of All Meetings” heading and does not expose any /noticeofmeeting/ anchors. Because extract_senate_notice_urls() only scrapes those anchors from the initial response, senate_urls will be empty in normal runs and the tracker will silently miss every Senate appearance.
Useful? React with 👍 / 👎.
| matching_lines <- lines[str_detect(lines, regex(organization_pattern, ignore_case = TRUE))] | ||
| if (length(matching_lines) == 0) { | ||
| return(NA_character_) | ||
| } | ||
|
|
There was a problem hiding this comment.
Extract representatives from witness entries
On both House and Senate notices, the organization name usually appears in agenda text or section headers, while the actual witnesses are listed on following lines without repeating the organization. Since this helper only keeps lines that themselves match organization_pattern, representative_name becomes agenda fragments or entire witness blocks instead of the named representatives (for example, Health notices mentioning Public Health Agency of Canada), which breaks one of the main output fields.
Useful? React with 👍 / 👎.
| normalized_members <- c(member_names, required_contacts$member_name) |> | ||
| normalize_text() |> | ||
| discard(~ !nzchar(.x)) |> | ||
| unique() |
There was a problem hiding this comment.
Keep forced contacts out of committee_members
Appending required_contacts$member_name here means every House result includes Adam Chambers and every Senate result includes Rosa Galvez even when they are not members of the matched committee. That corrupts the committee_members column for all outputs and can mislead downstream notification or auditing steps; if these contacts must always be reachable, only twitter_handles should be force-included.
Useful? React with 👍 / 👎.
Motivation
Description
canadian_parliamentary_appearance_tracker.R, an R script that scans House business pages and the Senate meetings schedule, filters notices by an organization name or aliases, extracts meeting details, and writes a normalized CSV output.README_canadian_parliamentary_appearance_tracker.mddocumenting usage, flags and environment variables, CRON and n8n examples, required R packages, output schema, and operational notes.twitter_handles_template.csvas a starter mapping used to enrich committee members with Twitter/X handles and include forced-includes for required contacts (Adam Chambers for House and Rosa Galvez for Senate).fetch_html,extract_*,parse_*helpers), handle missing data gracefully by writing an empty CSV with required headers, and provide CLI flags / environment variable overrides for--organization-name,--lookahead-days,--output-dir, and--twitter-map.Testing
Codex Task