Skip to content

Removing specific filters for heartbeat notifications - #2159

Merged
ben851 merged 7 commits into
mainfrom
refactor/rm-heartbeat-filters
Aug 31, 2026
Merged

Removing specific filters for heartbeat notifications#2159
ben851 merged 7 commits into
mainfrom
refactor/rm-heartbeat-filters

Conversation

@jimleroyer

@jimleroyer jimleroyer commented Apr 28, 2025

Copy link
Copy Markdown
Member

Summary | Résumé

Removing specific filters for heartbeat notifications. This won't be needed as we moved the heartbeat notifications into a dedicated service and after we rework the existing heartbeat in the database so they are associated with the new service.

Related task:
https://app.zenhub.com/workspaces/notify-planning-core-6411dfb7c95fb80014e0cab0/issues/gh/cds-snc/notification-planning-core/560

Test instructions | Instructions pour tester la modification

Test the dashboards that were affected with the filters, make sure these before and after the changes report the same numbers for previous periods of time.

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

This PR removes the specific heartbeat notification filters from the statistics gathering and dashboard rendering functions, as heartbeat notifications are now handled by a dedicated service. Key changes include:

  • Removing the filter_heartbeats parameter from get_latest_stats in app/utils.py.
  • Updating get_stats_by_month in app/notify_client/service_api_client.py to omit heartbeat filtering.
  • Adjusting view calls in app/main/views/index.py to stop passing the filter_heartbeats parameter.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
app/utils.py Removed heartbeat filtering in the get_latest_stats function.
app/notify_client/service_api_client.py Updated the API call by removing the filter_heartbeats parameter.
app/main/views/index.py Removed heartbeat filtering when rendering activity and articles.
Comments suppressed due to low confidence (1)

app/main/views/index.py:291

  • Ensure tests for the activity view are updated to confirm consistent statistics reporting after the removal of heartbeat filtering.
return render_template("views/activity.html", **get_latest_stats(get_current_locale(current_app)))

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Comment thread app/utils.py Outdated
emails_total += count

live_services = get_live_services_count()
live_services = len(service_api_client.get_live_services_data()["data"])

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@andrewleith Was this one an improvement that might have gone after that PR was made (many months ago)? Just want to have your eyes on that and what should be used.

Comment thread app/utils.py

@cache.memoize(timeout=24 * 60 * 60)
def get_live_services_count():
return len(service_api_client.get_live_services_data({"filter_heartbeats": True})["data"])

@jimleroyer jimleroyer Aug 31, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm I guess we could keep that one, especially for memoization, and let it be called in the other call site, but we need to remove filter_heartbeats. @andrewleith what do you prefer?

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.

Yeah I think we should keep the caching here - no need to hit the db often for these generalized statistics!

@jimleroyer jimleroyer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LGTM - let's have @andrewleith review as well.

@ben851
ben851 marked this pull request as ready for review August 31, 2026 18:01

@ben851 ben851 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.

LGTM, added the caching back

@ben851
ben851 force-pushed the refactor/rm-heartbeat-filters branch from 8a7a436 to 979bfbd Compare August 31, 2026 18:04
@ben851
ben851 merged commit e42d3d9 into main Aug 31, 2026
13 checks passed
@ben851
ben851 deleted the refactor/rm-heartbeat-filters branch August 31, 2026 18:14
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