Skip to content

Add Canadian parliamentary appearance tracker (R) with README and Twitter handles template - #5

Open
charles-hebert wants to merge 2 commits into
mainfrom
codex/build-r-script-for-appearance-tracker
Open

Add Canadian parliamentary appearance tracker (R) with README and Twitter handles template#5
charles-hebert wants to merge 2 commits into
mainfrom
codex/build-r-script-for-appearance-tracker

Conversation

@charles-hebert

Copy link
Copy Markdown
Owner

Motivation

  • Provide an automated way to detect the next scheduled appearance of a federal organization before Canadian parliamentary committees for use in CRON or n8n workflows.
  • Consolidate scraping logic for both House of Commons and Senate committee notices into a single script that emits a predictable CSV schema.
  • Allow enrichment of committee rosters with social handles via a static mapping to support notifications and downstream processing.

Description

  • Add 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.
  • Add README_canadian_parliamentary_appearance_tracker.md documenting usage, flags and environment variables, CRON and n8n examples, required R packages, output schema, and operational notes.
  • Add twitter_handles_template.csv as 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).
  • Implement defensive fetching and parsing (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

  • No automated tests were included or executed as part of this change.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +250 to +252
doc |>
html_elements(xpath = "//a[contains(@href, '/noticeofmeeting/')]") |>
html_attr("href") |>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +198 to +202
matching_lines <- lines[str_detect(lines, regex(organization_pattern, ignore_case = TRUE))]
if (length(matching_lines) == 0) {
return(NA_character_)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +135 to +138
normalized_members <- c(member_names, required_contacts$member_name) |>
normalize_text() |>
discard(~ !nzchar(.x)) |>
unique()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant