def get_endpoint_versions(db_session, endpoint_id, versions): """ :param db_session: session for the database :param endpoint_id: id for the endpoint :param versions: a list of version to be filtered on :return: a list of dicts with the performance of each version """ times = get_version_data_grouped(db_session, lambda x: simplify(x, 100), Request.endpoint_id == endpoint_id) first_requests = get_first_requests(db_session, endpoint_id) return [{ 'version': v, 'date': get_value(first_requests, v), 'values': get_value(times, v), 'color': get_color(v) } for v in versions]
def get_endpoint_users(db_session, endpoint_id, users): """ :param db_session: session for the database :param endpoint_id: id for the endpoint :param users: a list of users to be filtered on :return: a list of dicts with the performance of each user """ times = get_user_data_grouped(db_session, lambda x: simplify(x, 100), Request.endpoint_id == endpoint_id) first_requests = get_first_requests(db_session, endpoint_id) return [{ 'user': u, 'date': get_value(first_requests, u), 'values': get_value(times, u), 'color': get_color(u) } for u in users]
def version_ip_graph(db_session, endpoint_id, form): """ :param db_session: session for the database :param endpoint_id: the endpoint to filter the data on :param form: form for reducing the size of the graph :return: an HTML bubble plot """ users = get_ips(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.ip, 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': 'IP-addresses', 'type': 'category', 'autorange': 'reversed' }, margin=get_margin(b=200)) return get_figure(layout, trace)
def versions_graph(db_session, endpoint_id, form): times = get_version_data_grouped(db_session, lambda x: simplify(x, 10), Request.endpoint_id == endpoint_id) first_requests = get_first_requests(db_session, endpoint_id, form.get_slider_value()) data = [ boxplot(name=format_version( request.version_requested, get_value(first_requests, request.version_requested)), values=get_value(times, request.version_requested), marker={'color': get_color(request.version_requested)}) for request in first_requests ] layout = get_layout(height=350 + 40 * len(first_requests), xaxis={'title': 'Execution time (ms)'}, yaxis={ 'type': 'category', 'title': 'Version', 'autorange': 'reversed' }, margin=get_margin()) return get_figure(layout=layout, data=data)
def get_2d_version_data(session, endpoint_id, versions, column_data, column): """ :param session: session for the database :param endpoint_id: id of the endpoint :param versions: a list of versions :param column_data: a is of the other column :param column: column from the Request table :return: a dict with 2d information about the version and another column """ first_request = get_first_requests(session, endpoint_id) values = get_two_columns_grouped(session, column, Request.endpoint_id == endpoint_id) data = [[get_value(values, (data, v)) for v in versions] for data in column_data] return { 'versions': [{ 'version': v, 'date': get_value(first_request, v) } for v in versions], 'data': data, }