Skip to content

normalize_over_analysis_period crashes on the OVERALL window #3281

Description

@BryanBaird

This is a follow-up to the normalization fix (#3280). The patched logic still reads time_limits.analysis_length_dates in the OVERALL branch of Analysis.calculate_statistics (jetstream/analysis.py:1385), but TimeLimits has no such attribute.

The WEEK branch hardcodes 7 and dodges it; OVERALL hits the bad attribute and every run of a metric carrying normalize_over_analysis_period (e.g. daily_active_users_per_1000_clients_legacy) dies with:

AttributeError: 'TimeLimits' object has no attribute 'analysis_length_dates'. 

The fix seems to be to re-derive the length from the window start and end, which are accessible.

I've used this patch on a local Jetstream test run and it did properly apply the normalization to the metric for both the weekly and overall windows.

# jetstream/analysis.py, OVERALL branch (~line 1385)
-    analysis_length_dates = time_limits.analysis_length_dates
+    # TimeLimits has no `analysis_length_dates`; derive from the overall window.
+    # start/end are inclusive days since enrollment → length = end - start + 1.
+    overall_window = time_limits.analysis_windows[-1]
+    analysis_length_dates = overall_window.end - overall_window.start + 1

┆Issue is synchronized with this Jira Task

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions