<commit_before>"""Contains ResultView."""
from tornado.web import HTTPError
import logging

from .base import BaseHandler
from rubberband.models import TestSet
from rubberband.utils import ResultClient, write_file
from rubberband.constants import EXPORT_FILE_TYPES, IPET_EVALUATIONS


class ResultView(BaseHandler):
    """Request handler handling the results view."""

    def get(self, parent_id):
        """
        Answer to GET requests.

        Parameters
        ----------
        parent_id
            Rubberband id of parent

        Returns
        -------

        """
        # parent id is the first argument: meta id of TestSet
        if not parent_id:
            raise HTTPError(404)
        parent = TestSet.get(id=parent_id, ignore=404)

        if not parent:
            raise HTTPError(404)

        # get data associated with TestSet, save in parent.children[]
        parent.load_children()

        comparelist = self.get_argument("compare", default=None)

        if comparelist:
            compare_ids = comparelist.split(",")
            compare = load_testsets(compare_ids)
            for c in compare:
                c.load_children()

            all_runs = [parent] + compare
            same_status = get_same_status(all_runs)
            parent.load_stats(same_status)
            for c in compare:
                c.load_stats(same_status)
            # save intersection results and difference results
            sets = get_intersection_difference([c.children.to_dict().keys() for c in all_runs])
        else:
            sets = {}
            # save stats in parent.stats
            parent.load_stats()

        # construct link to download archive
        testset_ids = []
        if compare:
            testset_ids = compare_ids
        testset_ids.append(parent_id)
        downloadziplink = "/download?testsets=" + (",".join(testset_ids))

        metas = [key for md in [parent] + compare for key in md.to_dict().get('metadata', [])]
        meta = list(set(metas))
        meta.sort()
<commit_msg>add missing init of variable in resulthandler<commit_after>"""Contains ResultView."""
from tornado.web import HTTPError
import logging

from .base import BaseHandler
from rubberband.models import TestSet
from rubberband.utils import ResultClient, write_file
from rubberband.constants import EXPORT_FILE_TYPES, IPET_EVALUATIONS


class ResultView(BaseHandler):
    """Request handler handling the results view."""

    def get(self, parent_id):
        """
        Answer to GET requests.

        Parameters
        ----------
        parent_id
            Rubberband id of parent

        Returns
        -------

        """
        # parent id is the first argument: meta id of TestSet
        if not parent_id:
            raise HTTPError(404)
        parent = TestSet.get(id=parent_id, ignore=404)

        if not parent:
            raise HTTPError(404)

        # get data associated with TestSet, save in parent.children[]
        parent.load_children()

        compare = []
        comparelist = self.get_argument("compare", default=None)

        if comparelist:
            compare_ids = comparelist.split(",")
            compare = load_testsets(compare_ids)
            for c in compare:
                c.load_children()

            all_runs = [parent] + compare
            same_status = get_same_status(all_runs)
            parent.load_stats(same_status)
            for c in compare:
                c.load_stats(same_status)
            # save intersection results and difference results
            sets = get_intersection_difference([c.children.to_dict().keys() for c in all_runs])
        else:
            sets = {}
            # save stats in parent.stats
            parent.load_stats()

        # construct link to download archive
        testset_ids = []
        if compare:
            testset_ids = compare_ids
        testset_ids.append(parent_id)
        downloadziplink = "/download?testsets=" + (",".join(testset_ids))

        metas = [key for md in [parent] + compare for key in md.to_dict().get('metadata', [])]
        meta = list(set(metas))
        meta.sort()

{'fraction_non_alphanumeric': 0.09029617144233085, 'fraction_numerical': 0.004334216229231881, 'mean_word_length': 2.0589101620029453, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1986169', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1105, 'n_words': 311}