<commit_before>"""
Django view to allow the rest commands to
create new Zagg UniqueMetrics

"""
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from metric.metricmanager import UniqueMetric, MetricManager

#disabling these checks because we are extending the django framework
# and pylint isn't catching this
# Pylint isn't checking for APIView parent class, so disablign no-member check
#pylint: disable=too-many-public-methods,no-self-use,unused-argument,no-member
class MetricView(APIView):
    """
    Django view class to allow access to rest functions
    """
    def __init__(self):
        pass

    def post(self, request, *args, **kwargs):
        """
        implementation of the REST GET method
        """
        new_metric = UniqueMetric.from_request(request.data)
        mymm = MetricManager('/tmp/metrics')
        mymm.write_metrics(new_metric)

        return Response({"success": True})

    def get(self, request, *args, **kwargs):
        """
        implementation of the REST GET method
        """
        mymm = MetricManager('/tmp/metrics')
        results = mymm.read_metrics()

        res = []
        for uniqm in results:<commit_msg>removed metric from views<commit_after>"""
Django view to allow the rest commands to
create new Zagg UniqueMetrics

"""
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from metricmanager import UniqueMetric, MetricManager

#disabling these checks because we are extending the django framework
# and pylint isn't catching this
# Pylint isn't checking for APIView parent class, so disablign no-member check
#pylint: disable=too-many-public-methods,no-self-use,unused-argument,no-member
class MetricView(APIView):
    """
    Django view class to allow access to rest functions
    """
    def __init__(self):
        pass

    def post(self, request, *args, **kwargs):
        """
        implementation of the REST GET method
        """
        new_metric = UniqueMetric.from_request(request.data)
        mymm = MetricManager('/tmp/metrics')
        mymm.write_metrics(new_metric)

        return Response({"success": True})

    def get(self, request, *args, **kwargs):
        """
        implementation of the REST GET method
        """
        mymm = MetricManager('/tmp/metrics')
        results = mymm.read_metrics()

        res = []
        for uniqm in results:
{'fraction_non_alphanumeric': 0.08981071284736206, 'fraction_numerical': 0.0, 'mean_word_length': 3.203045685279188, 'pattern_counts': {'":': 2, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '892174', 'n_tokens_mistral': 682, 'n_tokens_neox': 668, 'n_words': 224}