<commit_before># -*- coding: utf-8 -*-
'''
    Mango HTTP tasks handlers.
'''

# This file is part of mango.

# Distributed under the terms of the last AGPL License.
# The full license is in the file LICENCE, distributed as part of this software.

__author__ = '<NAME>'


import time
import arrow
import motor

import logging

# import numpy as np
import pandas as pd

from bson import json_util

from tornado import gen
from tornado import web

from mango.system import accounts
from mango.system import tasks

from mango.tools import content_type_validation
from mango.tools import check_json
from mango.tools import check_times
from mango.tools import errors
from mango.tools import new_resource
from mango.tools import clean_structure

from mango.handlers import BaseHandler


@content_type_validation
class Handler(tasks.Tasks, accounts.Accounts, BaseHandler):
    '''
        Tasks HTTP request handlers
    '''

    @gen.coroutine
    def get(self, task_uuid=None, start=None, end=None, page_num=0, lapse='hours'):
        '''
            Get tasks handler
        '''

        # -- logging info

        logging.warning('daaaa fuck1!!{0}'.format(task_uuid))

        logging.info(self.request.arguments)

        #account = (self.request.arguments.get('account', [None])[0] if not account else account)

        # query string checked from string to boolean
        #checked = str2bool(str(self.request.arguments.get('checked', [False])[0]))

        if task_uuid:
            task_uuid = task_uuid.rstrip('/')

            if self.current_user:
                user = self.current_user
                task = yield self.get_task(user, task_uuid)
            else:
                task = yield self.get_task(None, task_uuid)

            if not task:
                self.set_status(400)
                system_error = errors.Error('missing')
                error = system_error.missing('task', task_uuid)
                self.finish(error)
                return

            logging.warning(clean_structure(task))

            self.finish(task)
            return

        if self.current_user:
            user = self.current_user
            orgs = yield self.get_orgs_list(user)
            
            account_list = (orgs['orgs'] if orgs else False)
            if not account_list:
                result = yield self.get_task_list(
                                        account=user, 
                                        lapse=lapse,
                                        start=start,
                                        end=end,
                                        page_num=page_num)
            else:<commit_msg>barbarians<commit_after># -*- coding: utf-8 -*-
'''
    Mango HTTP tasks handlers.
'''

# This file is part of mango.

# Distributed under the terms of the last AGPL License.
# The full license is in the file LICENCE, distributed as part of this software.

__author__ = '<NAME>'


import time
import arrow
import motor

import logging

# import numpy as np
import pandas as pd

from bson import json_util

from tornado import gen
from tornado import web

from mango.system import accounts
from mango.system import tasks

from mango.tools import content_type_validation
from mango.tools import check_json
from mango.tools import check_times
from mango.tools import errors
from mango.tools import new_resource
from mango.tools import clean_structure

from mango.handlers import BaseHandler


@content_type_validation
class Handler(tasks.Tasks, accounts.Accounts, BaseHandler):
    '''
        Tasks HTTP request handlers
    '''

    @gen.coroutine
    def get(self, task_uuid=None, start=None, end=None, page_num=0, lapse='hours'):
        '''
            Get tasks handler
        '''

        # -- logging info

        logging.warning('daaaa fuck1!!{0}'.format(task_uuid))

        logging.info(self.request.arguments)

        #account = (self.request.arguments.get('account', [None])[0] if not account else account)

        # query string checked from string to boolean
        #checked = str2bool(str(self.request.arguments.get('checked', [False])[0]))

        if task_uuid:
            task_uuid = task_uuid.rstrip('/')

            if self.current_user:
                user = self.current_user
                task = yield self.get_task(user, task_uuid)
            else:
                task = yield self.get_task(None, task_uuid)

            if not task:
                self.set_status(400)
                system_error = errors.Error('missing')
                error = system_error.missing('task', task_uuid)
                self.finish(error)
                return

            self.finish(clean_structure(task))
            return

        if self.current_user:
            user = self.current_user
            orgs = yield self.get_orgs_list(user)
            
            account_list = (orgs['orgs'] if orgs else False)
            if not account_list:
                result = yield self.get_task_list(
                                        account=user, 
                                        lapse=lapse,
                                        start=start,
                                        end=end,
                                        page_num=page_num)
            else:
{'fraction_non_alphanumeric': 0.08079847908745247, 'fraction_numerical': 0.0038022813688212928, 'mean_word_length': 1.8623503808487487, '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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1842380', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1340, 'n_words': 400}