<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Blueprint of the /countries route.
This route will be registered in `server.py`.

'''
import flask
import app.utilities.load as Load

from rq import Queue
from redis import Redis

from app.classes.ckan import CKAN
from app.functions.manage_queue import getStatus
from app.functions.fetch_store import fetchAndStore

ckan = CKAN().init()
queue = Queue(connection=Redis())
blueprint_countries = flask.Blueprint('countries', __name__)

@blueprint_countries.route('/countries')
def computeCountries():
    '''
    Computes information about all countries of a
    CKAN instance.

    '''
    status = getStatus('default')
    countries = ckan.action.group_list()
    if status['empty']:
      for country in countries:
        job = queue.enqueue(fetchAndStore, 'country', country)

    response = {
        'success': True,
        'message': 'Computing countries information.',
        'endpoint': 'countries',
        'time': None,
        'ETA': None,<commit_msg>improving json output of response<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Blueprint of the /countries route.
This route will be registered in `server.py`.

'''
import flask
import app.utilities.load as Load

from rq import Queue
from redis import Redis

from app.classes.ckan import CKAN
from app.functions.manage_queue import getStatus
from app.functions.fetch_store import fetchAndStore

ckan = CKAN().init()
queue = Queue(connection=Redis(), name='countries')
blueprint_countries = flask.Blueprint('countries', __name__)

@blueprint_countries.route('/countries')
def computeCountries():
    '''
    Computes information about all countries of a
    CKAN instance.

    '''
    status = getStatus('countries')
    countries = ckan.action.group_list()
    if status['empty']:
      for country in countries:
        job = queue.enqueue(fetchAndStore, 'country', country)

    response = {
        'success': True,
        'message': 'Computing countries information. {n} before finished.'.format(n=status['count']),
        'endpoint': 'countries',
        'time': None,
        'ETA': None,
{'fraction_non_alphanumeric': 0.12318501170960187, 'fraction_numerical': 0.000936768149882904, 'mean_word_length': 3.673960612691466, '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': '319498', 'n_tokens_mistral': 645, 'n_tokens_neox': 629, 'n_words': 181}