def get_monitor_statistics()

in mozetl/graphics/graphics_telemetry_dashboard.py [0:0]


def get_monitor_statistics():
    def get_monitor_rdds_for_index(data, i):
        def get_refresh_rate(p):
            refresh_rate = p[MonitorsKey][i].get("refreshRate", 0)
            return refresh_rate if refresh_rate > 1 else "Unknown"

        def get_resolution(p):
            return get_monitor_res(p, i)

        monitors_at_index = data.filter(lambda p: get_monitor_count(p) == monitor_count)
        monitors_at_index = repartition(monitors_at_index)
        refresh_rates = monitors_at_index.map(lambda p: (get_refresh_rate(p),))
        resolutions = monitors_at_index.map(lambda p: (get_resolution(p),))
        return refresh_rates, resolutions

    monitor_counts = windows_pings.map(lambda p: (get_monitor_count(p),)).countByKey()
    monitor_counts.pop(0, None)

    refresh_rates = None
    resolutions = None
    for monitor_count in monitor_counts:
        rate_subset, res_subset = get_monitor_rdds_for_index(
            windows_pings, monitor_count - 1
        )
        refresh_rates = union_pipelines(refresh_rates, rate_subset)
        resolutions = union_pipelines(resolutions, res_subset)

    monitor_refresh_rates = refresh_rates.countByKey()
    monitor_resolutions = resolutions.countByKey()

    return {
        "counts": monitor_counts,
        "refreshRates": monitor_refresh_rates,
        "resolutions": monitor_resolutions,
    }