<commit_before>from flask import render_template, request, redirect

from . import traces
from .. import db

from ..utils import ParseTraceURLId


@traces.route('/<hex_trace_id>', methods=['GET'])
def traces(hex_trace_id):
    # hex trace_id converted to long
    traceId = str(ParseTraceURLId(hex_trace_id))

    # find the number of DISTINCT spans, that above service connects with
    query = "SELECT COUNT(DISTINCT span_name) as spanCount, COUNT(DISTINCT service_name) as serviceCount  \
            FROM zipkin_annotations \
            GROUP BY trace_id, span_name, service_name \
            HAVING \
            trace_id = %s \
            ORDER BY a_timestamp DESC" \
            % str(traceId)
    result = connection.execute(query)



    return render_template('trace.html')<commit_msg>simplifying query for fetching trace information<commit_after>from flask import render_template, request, redirect

from . import traces
from .. import db

from ..utils import ParseTraceURLId


@traces.route('/<hex_trace_id>', methods=['GET'])
def traces(hex_trace_id):
    # hex trace_id converted to long
    traceId = str(ParseTraceURLId(hex_trace_id))

    # get database engine connection
    connection = db.engine.connect()

    # find the number of DISTINCT spans, that above service connects with
    query = "SELECT *  \
            FROM zipkin_annotations \
            WHERE \
            trace_id = %s \
            ORDER BY a_timestamp DESC" \
            % str(traceId)
    resultAnnotations = connection.execute(query)


    return render_template('trace.html')
{'fraction_non_alphanumeric': 0.08317460317460318, 'fraction_numerical': 0.0, 'mean_word_length': 2.94, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3358026', 'n_tokens_mistral': 464, 'n_tokens_neox': 438, 'n_words': 131}