# Path: htm-site/htmsite/util.py
# def get_accident_near(time_start, time_end, intersection, radius=150, request=None):
# def du(unix):
# def validate_nodes(nodes, request):
# def update_neighbours(request):
# def update_neighbour_list(request):
# 
# Path: htm-site/htmsite/reports.py
# REPORTS = ('Daily Total', 'Monthly Average', 'AM Peak', 'PM Peak',
#            'Highest Peak Volumes', 'Highest AM Peaks',
#            'Highest PM Peaks', 'Phase Splits',
#            'Degree of Saturation', 'VO VK Ratio')


import json
import pymongo
from datetime import timedelta, datetime
from collections import defaultdict
from pyramid.httpexceptions import HTTPNotFound
from pyramid.request import Request
from .util import du, get_accident_near, date_format
from .reports import REPORTS
from pluck import pluck
from pyramid import exceptions as exc
from pyramid.view import view_config
            'time_end': end_date,
            'scats_diagrams': neighbour_diagrams,
            'reports': REPORTS,
            'max_vehicles': request.registry.settings['max_vehicles'],
            'date_format': date_format
            }


@view_config(route_name='readings_anomaly_json', renderer='pymongo_cursor')
def get_readings_anomaly_json(request):
    """

    :param request:
    :return:
    """

    args = request.matchdict
    request.response.content_type = 'application/json'
    ft = request.GET.get('from', None)
    tt = request.GET.get('to', None)
    if ft is not None:
        ft = int(ft)
    if tt is not None:
        tt = int(tt)
    return get_anomaly_scores(ft, tt, args['intersection'], request=request)


@view_config(route_name='readings_vs_sm_anomalies', renderer='bson', request_method='GET')
def get_readings_vs_sm_anomalies(request: Request):
    out = defaultdict(dict)

# Path: htm-site/htmsite/util.py
# def get_accident_near(time_start, time_end, intersection, radius=150, request=None):
# def du(unix):
# def validate_nodes(nodes, request):
# def update_neighbours(request):
# def update_neighbour_list(request):
# 
# Path: htm-site/htmsite/reports.py
# REPORTS = ('Daily Total', 'Monthly Average', 'AM Peak', 'PM Peak',
#            'Highest Peak Volumes', 'Highest AM Peaks',
#            'Highest PM Peaks', 'Phase Splits',
#            'Degree of Saturation', 'VO VK Ratio')


# Path: htm-site/htmsite/intersection.py
import json
import pymongo
from datetime import timedelta, datetime
from collections import defaultdict
from pyramid.httpexceptions import HTTPNotFound
from pyramid.request import Request
from .util import du, get_accident_near, date_format
from .reports import REPORTS
from pluck import pluck
from pyramid import exceptions as exc
from pyramid.view import view_config

            'time_end': end_date,
            'scats_diagrams': neighbour_diagrams,
            'reports': REPORTS,
            'max_vehicles': request.registry.settings['max_vehicles'],
            'date_format': date_format
            }


@view_config(route_name='readings_anomaly_json', renderer='pymongo_cursor')
def get_readings_anomaly_json(request):
    """

    :param request:
    :return:
    """

    args = request.matchdict
    request.response.content_type = 'application/json'
    ft = request.GET.get('from', None)
    tt = request.GET.get('to', None)
    if ft is not None:
        ft = int(ft)
    if tt is not None:
        tt = int(tt)
    return get_anomaly_scores(ft, tt, args['intersection'], request=request)


@view_config(route_name='readings_vs_sm_anomalies', renderer='bson', request_method='GET')
def get_readings_vs_sm_anomalies(request: Request):
    out = defaultdict(dict)

    ft = du(request.GET['from'])