<commit_before>from dogapi import dog_stats_api

import logging
from .grading_service_module import GradingService

log = logging.getLogger(__name__)


class ControllerQueryService(GradingService):
    """
    Interface to controller query backend.
    """

    METRIC_NAME = 'edxapp.open_ended_grading.controller_query_service'

    def __init__(self, config, system):
        config['system'] = system
        super(ControllerQueryService, self).__init__(config)
        self.url = config['url'] + config['grading_controller']
        self.login_url = self.url + '/login/'
        self.check_eta_url = self.url + '/get_submission_eta/'
        self.combined_notifications_url = self.url + '/combined_notifications/'
        self.grading_status_list_url = self.url + '/get_grading_status_list/'
        self.flagged_problem_list_url = self.url + '/get_flagged_problem_list/'
        self.take_action_on_flags_url = self.url + '/take_action_on_flags/'

    def check_for_eta(self, location):
        params = {
            'location': location,
        }
        data = self.get(self.check_eta_url, params)
        self._record_result('check_for_eta', data)
        dog_stats_api.histogram(self._metric_name('check_for_eta.eta'), data.get('eta', 0))

        return data

    def check_combined_notifications(self, course_id, student_id, user_is_staff, last_time_viewed):
        params = {
            'student_id': student_id,
            'course_id': course_id,
            'user_is_staff': user_is_staff,
            'last_time_viewed': last_time_viewed,
        }
        log.debug(self.combined_notifications_url)
        data = self.get(self.combined_notifications_url, params)

        tags = [u'course_id:{}'.format(course_id), u'user_is_staff:{}'.format(user_is_staff)]
        tags.extend(
            u'{}:{}'.format(key, value)<commit_msg>Fix @feanil Traceback from Logs(TypeError: 'SlashSeparatedCourseKey' object is not iterable)<commit_after>from dogapi import dog_stats_api

import logging
from .grading_service_module import GradingService

log = logging.getLogger(__name__)


class ControllerQueryService(GradingService):
    """
    Interface to controller query backend.
    """

    METRIC_NAME = 'edxapp.open_ended_grading.controller_query_service'

    def __init__(self, config, system):
        config['system'] = system
        super(ControllerQueryService, self).__init__(config)
        self.url = config['url'] + config['grading_controller']
        self.login_url = self.url + '/login/'
        self.check_eta_url = self.url + '/get_submission_eta/'
        self.combined_notifications_url = self.url + '/combined_notifications/'
        self.grading_status_list_url = self.url + '/get_grading_status_list/'
        self.flagged_problem_list_url = self.url + '/get_flagged_problem_list/'
        self.take_action_on_flags_url = self.url + '/take_action_on_flags/'

    def check_for_eta(self, location):
        params = {
            'location': location,
        }
        data = self.get(self.check_eta_url, params)
        self._record_result('check_for_eta', data)
        dog_stats_api.histogram(self._metric_name('check_for_eta.eta'), data.get('eta', 0))

        return data

    def check_combined_notifications(self, course_id, student_id, user_is_staff, last_time_viewed):
        params = {
            'student_id': student_id,
            'course_id': course_id.to_deprecated_string(),
            'user_is_staff': user_is_staff,
            'last_time_viewed': last_time_viewed,
        }
        log.debug(self.combined_notifications_url)
        data = self.get(self.combined_notifications_url, params)

        tags = [u'course_id:{}'.format(course_id), u'user_is_staff:{}'.format(user_is_staff)]
        tags.extend(
            u'{}:{}'.format(key, value)
{'fraction_non_alphanumeric': 0.11061481870730426, 'fraction_numerical': 0.0005254860746190226, 'mean_word_length': 3.2536312849162012, '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': '5110336', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1192, 'n_words': 190}