Example #1
0
def build_analytics_data(realm_count_query: Any,
                         installation_count_query: Any) -> Tuple[List[Dict[str, Any]],
                                                                 List[Dict[str, Any]]]:
    data = {}
    data['analytics_realmcount'] = [
        model_to_dict(realm_count) for realm_count in realm_count_query.order_by("id")
    ]
    data['analytics_installationcount'] = [
        model_to_dict(count) for count in installation_count_query.order_by("id")
    ]

    floatify_datetime_fields(data, 'analytics_realmcount')
    floatify_datetime_fields(data, 'analytics_installationcount')
    return (data['analytics_realmcount'], data['analytics_installationcount'])
Example #2
0
def build_analytics_data(realm_count_query: Any,
                         installation_count_query: Any) -> Tuple[List[Dict[str, Any]],
                                                                 List[Dict[str, Any]]]:
    # We limit the batch size on the client side to avoid OOM kills timeouts, etc.
    MAX_CLIENT_BATCH_SIZE = 10000
    data = {}
    data['analytics_realmcount'] = [
        model_to_dict(realm_count) for realm_count in
        realm_count_query.order_by("id")[0:MAX_CLIENT_BATCH_SIZE]
    ]
    data['analytics_installationcount'] = [
        model_to_dict(count) for count in
        installation_count_query.order_by("id")[0:MAX_CLIENT_BATCH_SIZE]
    ]

    floatify_datetime_fields(data, 'analytics_realmcount')
    floatify_datetime_fields(data, 'analytics_installationcount')
    return (data['analytics_realmcount'], data['analytics_installationcount'])
Example #3
0
def build_analytics_data(
    realm_count_query: Any, installation_count_query: Any,
    realmauditlog_query: Any
) -> Tuple[List[Dict[str, Any]], List[Dict[str, Any]], List[Dict[str, Any]]]:
    # We limit the batch size on the client side to avoid OOM kills timeouts, etc.
    MAX_CLIENT_BATCH_SIZE = 10000
    data = {}
    data["analytics_realmcount"] = [
        model_to_dict(row)
        for row in realm_count_query.order_by("id")[0:MAX_CLIENT_BATCH_SIZE]
    ]
    data["analytics_installationcount"] = [
        model_to_dict(row) for row in installation_count_query.order_by("id")
        [0:MAX_CLIENT_BATCH_SIZE]
    ]
    data["zerver_realmauditlog"] = [
        model_to_dict(row, fields=REALMAUDITLOG_PUSHED_FIELDS)
        for row in realmauditlog_query.order_by("id")[0:MAX_CLIENT_BATCH_SIZE]
    ]

    floatify_datetime_fields(data, "analytics_realmcount")
    floatify_datetime_fields(data, "analytics_installationcount")
    floatify_datetime_fields(data, "zerver_realmauditlog")
    return (
        data["analytics_realmcount"],
        data["analytics_installationcount"],
        data["zerver_realmauditlog"],
    )