<commit_before>from swampdragon import route_handler
from swampdragon.route_handler import BaseModelPublisherRouter
from serializers import TransactionSerializer, ApySocketSerializer, LogEntrySerializer
from models import Transaction, LogEntry

from swampdragon.permissions import login_required

import logging
logger = logging.getLogger(__name__)


class PrivateBaseModelPublisherRouter(BaseModelPublisherRouter):

    @login_required
    def subscribe(self, **kwargs):
        super(BaseModelPublisherRouter, self).subscribe(**kwargs)


class TransactionRouter(PrivateBaseModelPublisherRouter):
    serializer_class = TransactionSerializer
    model = Transaction
    route_name = 'transaction-router'
    include_related = [ApySocketSerializer]

    def get_object(self, **kwargs):
        logger.info(kwargs)
        return self.model.objects.get(pk=kwargs['pk'])

    def get_query_set(self, **kwargs):
        logger.info(kwargs)
        return self.model.all()

    def get_subscription_contexts(self, **kwargs):
        return {'apy__base__user_id': self.connection.user.pk}


class LogRouter(PrivateBaseModelPublisherRouter):
    serializer_class = LogEntrySerializer
    model = LogEntry
    route_name = 'logentry-router'

    def get_object(self, **kwargs):
        logger.info(kwargs)
        return self.model.objects.get(pk=kwargs['pk'])

    def get_query_set(self, **kwargs):
        logger.info(kwargs)
        return self.model.all()

#    def get_subscription_contexts(self, **kwargs):
#        return {'transaction__apy__base__user_id': self.connection.user.pk}

route_handler.register(TransactionRouter)
route_handler.register(LogRouter)<commit_msg>reduce logging<commit_after>from swampdragon import route_handler
from swampdragon.route_handler import BaseModelPublisherRouter
from serializers import TransactionSerializer, ApySocketSerializer, LogEntrySerializer
from models import Transaction, LogEntry

from swampdragon.permissions import login_required

import logging
logger = logging.getLogger(__name__)


class PrivateBaseModelPublisherRouter(BaseModelPublisherRouter):

    @login_required
    def subscribe(self, **kwargs):
        super(BaseModelPublisherRouter, self).subscribe(**kwargs)


class TransactionRouter(PrivateBaseModelPublisherRouter):
    serializer_class = TransactionSerializer
    model = Transaction
    route_name = 'transaction-router'
    include_related = [ApySocketSerializer]

    def get_object(self, **kwargs):
        #logger.info(kwargs)
        return self.model.objects.get(pk=kwargs['pk'])

    def get_query_set(self, **kwargs):
        #logger.info(kwargs)
        return self.model.all()

    def get_subscription_contexts(self, **kwargs):
        return {'apy__base__user_id': self.connection.user.pk}


class LogRouter(PrivateBaseModelPublisherRouter):
    serializer_class = LogEntrySerializer
    model = LogEntry
    route_name = 'logentry-router'

    def get_object(self, **kwargs):
        #logger.info(kwargs)
        return self.model.objects.get(pk=kwargs['pk'])

    def get_query_set(self, **kwargs):
        #logger.info(kwargs)
        return self.model.all()

#    def get_subscription_contexts(self, **kwargs):
#        return {'transaction__apy__base__user_id': self.connection.user.pk}

route_handler.register(TransactionRouter)
route_handler.register(LogRouter)
{'fraction_non_alphanumeric': 0.09137055837563451, 'fraction_numerical': 0.0, 'mean_word_length': 4.756013745704467, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4395567', 'n_tokens_mistral': 952, 'n_tokens_neox': 906, 'n_words': 182}