def users(endpoint_id): """ :param endpoint_id: integer :return: A JSON-list with all users of a specific endpoint (user represented by a string) """ with session_scope() as session: users_hits = get_users(session, endpoint_id) dicts = [] for uh in users_hits: dicts.append({'user': uh[0], 'hits': uh[1]}) return jsonify(dicts)
def version_user_graph(db_session, endpoint_id, form): """ :param db_session: session for the database :param endpoint_id: the endpoint_id to filter the data on :param form: form for reducing the size of the graph :return: an HTML bubble plot """ users = get_users(db_session, endpoint_id, form.get_slider_value(0)) versions = get_versions(db_session, endpoint_id, form.get_slider_value(1)) first_request = get_first_requests(db_session, endpoint_id) values = get_two_columns_grouped(db_session, Request.group_by, Request.endpoint_id == endpoint_id) data = [[get_value(values, (user, v)) for v in versions] for user in users] average = get_average_bubble_size(data) trace = [ scatter(x=[ format_version(v, get_value(first_request, v)) for v in versions ], hovertext=[ 'Time: {:,.1f}ms'.format(data[i][j]) for j in range(len(versions)) ], y=[users[i]] * len(versions), name=users[i], mode='markers', marker={ 'color': [get_color(users[i])] * len(versions), 'size': [math.sqrt(d) for d in data[i]], 'sizeref': average, 'sizemode': 'area' }) for i in range(len(users)) ] layout = get_layout(height=350 + 40 * len(trace), xaxis={ 'title': 'Versions', 'type': 'category' }, yaxis={ 'title': 'Users', 'type': 'category', 'autorange': 'reversed' }, margin=get_margin(b=200)) return get_figure(layout, trace)
def users_graph(id, form): """ Return an HTML box plot with a specific number of :param id: get the data for this endpoint only :param form: instance of SliderForm :return: """ with session_scope() as db_session: users = get_users(db_session, id, form.get_slider_value()) times = get_user_data_grouped(db_session, lambda x: simplify(x, 10), Request.endpoint_id == id) data = [boxplot(name=u, values=get_value(times, u)) for u in users] layout = get_layout(height=350 + 40 * len(data), xaxis={'title': 'Execution time (ms)'}, yaxis={ 'type': 'category', 'title': 'User' }) return get_figure(layout, data)