<commit_before># Packages
import time
import json
from flask import Blueprint, Response, current_app

from datapunt_geosearch.datasource import BagDataSource, \
    NapMeetboutenDataSource
from datapunt_geosearch.registry import registry

health = Blueprint('health', __name__)


@health.route('/status', methods=['GET', 'HEAD', 'OPTIONS'])
def system_status():
    message = json.dumps({
        "Delay": registry.INITIALIZE_DELAY,
        "Datasets initialized": registry._datasets_initialized,
        "Time since last refresh": time.time() - (registry._datasets_initialized or time.time())
    })
    return Response(message,
                    content_type='application/json')


@health.route('/status/force-refresh', methods=['GET', 'HEAD', 'OPTIONS'])
def force_refresh():
    registry._datasets_initialized = time.time()
    registry.init_datasets()
    return system_status()

@health.route('/status/dataset/<dataset>/', methods=['GET', 'HEAD', 'OPTIONS'])
def dataset_details(dataset):
    dataset = registry.get_by_name(dataset)
    if dataset is None:
        result = dict(error='Meh')
        status = 400
    else:
        result = dict(
            name=dataset.__class__,
            data=repr(dataset.__dict__)
        )
        status = 200
    return Response(json.dumps(result), content_type='application/json', status=status)


@health.route('/status/health', methods=['GET', 'HEAD', 'OPTIONS'])
def search_list():
    """Execute test query against datasources"""
    x, y, response_text = 120993, 485919, []
    # Trying to load the data sources
    try:
        bag_dsn = BagDataSource(dsn=current_app.config['DSN_BAG'])
        nap_dsn = NapMeetboutenDataSource(dsn=current_app.config['DSN_NAP'])
    except Exception as e:
        return repr(e), 500
    # Attempting to query
    try:
        results = bag_dsn.query(x, y)
    except Exception as e:
        return repr(e), 500

    if results['type'] == 'Error':
        return Response(results['message'],
                        content_type='text/plain; charset=utf-8',
                        status=500)

    if not len(results['features']):<commit_msg>Revert "DEBUG URL. WILL NOT BE PUBLISHED TO PROD."<commit_after># Packages
import time
import json
from flask import Blueprint, Response, current_app

from datapunt_geosearch.datasource import BagDataSource, \
    NapMeetboutenDataSource
from datapunt_geosearch.registry import registry

health = Blueprint('health', __name__)


@health.route('/status', methods=['GET', 'HEAD', 'OPTIONS'])
def system_status():
    message = json.dumps({
        "Delay": registry.INITIALIZE_DELAY,
        "Datasets initialized": registry._datasets_initialized,
        "Time since last refresh": time.time() - (registry._datasets_initialized or time.time())
    })
    return Response(message,
                    content_type='application/json')


@health.route('/status/force-refresh', methods=['GET', 'HEAD', 'OPTIONS'])
def force_refresh():
    registry._datasets_initialized = time.time()
    registry.init_datasets()
    return system_status()


@health.route('/status/health', methods=['GET', 'HEAD', 'OPTIONS'])
def search_list():
    """Execute test query against datasources"""
    x, y, response_text = 120993, 485919, []
    # Trying to load the data sources
    try:
        bag_dsn = BagDataSource(dsn=current_app.config['DSN_BAG'])
        nap_dsn = NapMeetboutenDataSource(dsn=current_app.config['DSN_NAP'])
    except Exception as e:
        return repr(e), 500
    # Attempting to query
    try:
        results = bag_dsn.query(x, y)
    except Exception as e:
        return repr(e), 500

    if results['type'] == 'Error':
        return Response(results['message'],
                        content_type='text/plain; charset=utf-8',
                        status=500)

    if not len(results['features']):
{'fraction_non_alphanumeric': 0.12707900207900208, 'fraction_numerical': 0.012993762993762994, 'mean_word_length': 3.329583802024747, 'pattern_counts': {'":': 6, '<': 4, '<?xml version=': 0, '>': 4, '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': '1457501', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1120, 'n_words': 270}