Skip to content

feat: change tracker email template#1738

Merged
Alessandro100 merged 1 commit into
mainfrom
feat/198-notifications-email-template
Jul 23, 2026
Merged

feat: change tracker email template#1738
Alessandro100 merged 1 commit into
mainfrom
feat/198-notifications-email-template

Conversation

@Alessandro100

Copy link
Copy Markdown
Contributor

Summary:

This email is still going to junk in Outlook which is relevant to: MobilityData/mobilitydatabase-web#121

closes: https://github.com/MobilityData/product-tasks/issues/198

Introduces the email template to use for notification changes based on the gtfs diff schema. Also includes features not included in the schema like: validation diff, feature diff, breaking changes, and suspicious changes

Expected behavior:

When we are ready to send emails regarding the gtfs change notifications, this email template will format it nicely

Testing tips:

At the root of the mobility-feeds-api run

cd api/src

python - <<'EOF'
from pathlib import Path
from jinja2 import Environment, FileSystemLoader, select_autoescape

def thousands_sep(n):
    if n is None or n == "": return "—"
    try: return "{:,}".format(int(n))
    except: return "—"

env = Environment(
    loader=FileSystemLoader("email_templates"),
    autoescape=select_autoescape(["html", "jinja2"]),
)
env.filters["thousands_sep"] = thousands_sep

context = {
    "notification_date": "June 11, 2026",
    "subscriptions_url": "https://mobilitydatabase.org/subscriptions",
    "feeds": [{
        "feed_id": "mdb-2126",
        "feed_name": "Sample Transit Agency",
        "feed_url": "https://mobilitydatabase.org/feeds/mdb-2126/diff",
        "unsubscribe_url": "https://mobilitydatabase.org/feeds/mdb-2126/unsubscribe",
        "notification_date": "June 11, 2026",
        "base_feed_version": "2026-05-01", "new_feed_version": "2026-06-11",
        "total_changes": 42, "files_modified_count": 3,
        "breaking_changes": [{"type": "REMOVED ENTITY", "file": "trips.txt", "description": "12 trips removed."}],
        "suspicious_changes": [{"type": "LARGE ENTITY COUNT DELTA", "file": "stop_times.txt", "description": "Count dropped >20%."}],
        "diff_files": [
            {"file_name": "trips.txt", "rows_added_count": 5, "rows_deleted_count": 12, "rows_modified_count": 3},
            {"file_name": "calendar.txt", "rows_added_count": 2, "rows_deleted_count": 0, "rows_modified_count": None},
        ],
        "features_changed": [{"name": "Stops Wheelchair Accessibility", "change": "Added"}],
        "validation_changes": [
            {"change_type": "New", "notice_code": "missing_required_field", "severity": "ERROR", "older_count": None, "latest_count": 3},
            {"change_type": "Fixed", "notice_code": "invalid_url", "severity": "WARNING", "older_count": 2, "latest_count": None},
        ],
    }],
}

Path("/tmp/preview.html").write_text(
    env.get_template("change_tracker_email.html.jinja2").render(**context)
)
print("Saved to /tmp/preview.html")
EOF

open /tmp/preview.html

which will open up a preview. You can modify the values accordingly

Follow up tickets

  • Link the "View Full Report" buttons to actual links
  • Link the "Manage Notifications" to an actual page

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with ./scripts/api-tests.sh to make sure you didn't break anything
  • Add or update any needed documentation to the repo
  • Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s)
Screenshot 2026-06-11 at 15 01 48 Screenshot 2026-06-11 at 15 01 57 Screenshot 2026-06-11 at 15 02 09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Jinja2 HTML email template intended to format GTFS change-tracker notifications (diff summary + breaking/suspicious changes + feature and validation diffs) for eventual outbound email delivery.

Changes:

  • Introduces change_tracker_email.html.jinja2 with a multi-feed table-of-contents and per-feed sections.
  • Adds rendering for diff summary stats, breaking/suspicious change callouts, feature changes, and validation report diffs.
  • Includes email-client specific markup (e.g., Outlook/VML button) and responsive styles.

Comment thread api/src/email_templates/change_tracker_email.html.jinja2
Comment thread api/src/email_templates/change_tracker_email.html.jinja2
Comment thread api/src/email_templates/change_tracker_email.html.jinja2
@emmambd

emmambd commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

This looks great as a base for the change tracker! I'm wondering if we need another email template as well for the more general notifications (e.g. feed URL updated)

@Alessandro100
Alessandro100 force-pushed the feat/198-notifications-email-template branch from 133a254 to 6bf917b Compare July 23, 2026 13:26

@davidgamez davidgamez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@Alessandro100
Alessandro100 merged commit 0eeae08 into main Jul 23, 2026
21 of 22 checks passed
@Alessandro100
Alessandro100 deleted the feat/198-notifications-email-template branch July 23, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants