def write_firefox_legacy_metadata()

in etl/firefox_legacy_etl.py [0:0]


def write_firefox_legacy_metadata(output_dir, functions_dir):
    # pull down the recorded in process information, which we use as the
    # authoritative guide on whether a legacy probe is still "active"
    recorded_in_process_data = requests.get(PROBE_RECORDED_IN_PROCESSES_URL).json()
    activity_mapping = {row["metric"]: row["processes"] for row in recorded_in_process_data}

    # get the actual probe data
    probe_data = requests.get(PROBES_URL).json()

    # then write it out
    probe_output_directory = os.path.join(output_dir, "firefox_legacy", "metrics")
    os.makedirs(probe_output_directory, exist_ok=True)

    probe_summary = _get_legacy_firefox_metric_summary(probe_data, activity_mapping)
    for probe_name, probe_metadata in probe_summary.items():
        with open(os.path.join(probe_output_directory, f"data_{probe_name}.json"), "w") as f:
            json.dump(probe_metadata, f)

    # write a search index for legacy telemetry data
    open(os.path.join(functions_dir, "metrics_search_firefox_legacy.js"), "w").write(
        create_metrics_search_js(probe_summary.values(), legacy=True)
    )

    # write a search index for legacy telemetry + FOG data
    open(os.path.join(functions_dir, "metrics_search_fog_and_legacy.js"), "w").write(
        create_metrics_search_js(probe_summary.values(), app_name="fog_and_legacy", legacy=True)
    )