Shared period/site filter handling for the report LiveViews.
Every report page answers the same two questions — when and which site — and keeps both in the URL so a filtered view can be bookmarked, shared, and survives a refresh. This module owns that plumbing so the five pages don't each reimplement it.
Summary
Functions
Reads period and site from the URL params and assigns :filter,
:period, :site, :sites, and :bucket.
Applies the current filter's params to another report path.
Builds the URL to patch to when the filter form changes.
The current filter as URL params, for links between report pages that should keep the selected window.
Functions
@spec assign_filter(Phoenix.LiveView.Socket.t(), map()) :: Phoenix.LiveView.Socket.t()
Reads period and site from the URL params and assigns :filter,
:period, :site, :sites, and :bucket.
Unknown period values fall back to the default rather than erroring — these come from a URL anyone can edit.
@spec link_to(String.t(), PhoenixKitWebAnalytics.Reports.filter()) :: String.t()
Applies the current filter's params to another report path.
Builds the URL to patch to when the filter form changes.
Empty values are dropped, so the default view has a clean URL.
@spec to_params(PhoenixKitWebAnalytics.Reports.filter()) :: map()
The current filter as URL params, for links between report pages that should keep the selected window.