<commit_before># -*- coding: utf-8 -*- 

from django.contrib.auth.decorators import login_required
from django.views.generic.simple import direct_to_template
from django.conf import settings
from django.utils.translation import ugettext as _

import os
import pymongo
from pprint import pformat

from utils.io import pickle_load_obj
from utils.date import today_date
from utils import clogging
log = clogging.getColorLogger(__name__)

@login_required
def index(request):
    user_id = request.user.username
    msg = ''
    err = ''

    with pymongo.Connection(port=settings.MONGO_PORT) as connection:
        db = connection['pergenie']
        catalog_info = db['catalog_info']
        data_info = db['data_info']

        while True:
            # latest catalog importing date
            catalog_latest_importing_document = catalog_info.find_one({'status': 'latest'})
            if catalog_latest_importing_document:
                catalog_latest_importing_date = str(catalog_latest_importing_document['date'].date()).replace('-', '_')
            else:
                # TODO: error handling
                catalog_latest_importing_date = None
                err = 'latest catalog does not exist'

            # latest new catalog records date
            catalog_summary = pickle_load_obj(os.path.join(settings.CATALOG_SUMMARY_CACHE_DIR, 'catalog_summary.p'))
            catalog_latest_new_records_data = sorted(catalog_summary.get('added').items())[-1]

            # user's latest riskreport date
            risk_report_latest_date = {}
            user_datas = list(data_info.find({'user_id': user_id}))
            for user_data in user_datas:
                risk_report_latest_date[user_data['name']] = user_data.get('riskreport', None)

                if risk_report_latest_date[user_data['name']]:
                    # if riskreport is outdated, show diff of records (& link to riskreport)<commit_msg>logging locale<commit_after># -*- coding: utf-8 -*- 

from django.contrib.auth.decorators import login_required
from django.views.generic.simple import direct_to_template
from django.conf import settings
from django.utils import translation
from django.utils.translation import ugettext as _

import os
import pymongo
from pprint import pformat

from utils.io import pickle_load_obj
from utils.date import today_date
from utils import clogging
log = clogging.getColorLogger(__name__)

@login_required
def index(request):
    user_id = request.user.username
    msg = ''
    err = ''

    # log.debug('request.LANGUAGE_CODE {}'.format(request.LANGUAGE_CODE))
    log.debug('translation.get_language() {}'.format(translation.get_language()))
    # translation.activate('ja')

    with pymongo.Connection(port=settings.MONGO_PORT) as connection:
        db = connection['pergenie']
        catalog_info = db['catalog_info']
        data_info = db['data_info']

        while True:
            # latest catalog importing date
            catalog_latest_importing_document = catalog_info.find_one({'status': 'latest'})
            if catalog_latest_importing_document:
                catalog_latest_importing_date = str(catalog_latest_importing_document['date'].date()).replace('-', '_')
            else:
                # TODO: error handling
                catalog_latest_importing_date = None
                err = 'latest catalog does not exist'

            # latest new catalog records date
            catalog_summary = pickle_load_obj(os.path.join(settings.CATALOG_SUMMARY_CACHE_DIR, 'catalog_summary.p'))
            catalog_latest_new_records_data = sorted(catalog_summary.get('added').items())[-1]

            # user's latest riskreport date
            risk_report_latest_date = {}
            user_datas = list(data_info.find({'user_id': user_id}))
            for user_data in user_datas:
                risk_report_latest_date[user_data['name']] = user_data.get('riskreport', None)

                if risk_report_latest_date[user_data['name']]:
                    # if riskreport is outdated, show diff of records (& link to riskreport)
{'fraction_non_alphanumeric': 0.0922020598332516, 'fraction_numerical': 0.000980872976949485, 'mean_word_length': 3.0147637795275593, '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': '797242', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1110, 'n_words': 253}