<s> from flask import render_template , Blueprint <EOL> from controller import db <EOL> from model . drop_point import DropPoint <EOL> from model . report import Report <EOL> from model . visit import Visit <EOL> stats = Blueprint ( "<STR_LIT>" , __name__ ) <EOL> @ stats . route ( "<STR_LIT>" ) <EOL> def statistics ( ) : <EOL> return render_template ( <EOL> "<STR_LIT>" , <EOL> stats = Statistics ( ) <EOL> ) <EOL> class Statistics ( ) : <EOL> @ property <EOL> def drop_point_count ( self ) : <EOL> return DropPoint . query . count ( ) <EOL> @ property <EOL> def report_count ( self ) : <EOL> return Report . query . count ( ) <EOL> @ property <EOL> def visit_count ( self ) : <EOL> return Visit . query . count ( ) <EOL> @ property <EOL> def drop_points_by_state ( self ) : <EOL> ret = { } <EOL> for state in Report . states : <EOL> ret [ state ] = <NUM_LIT:0> <EOL> for dp in DropPoint . query . all ( ) : <EOL> if not dp . removed : <EOL> s = dp . get_last_state ( ) <EOL> ret [ s ] = ret [ s ] + <NUM_LIT:1> if s in ret else <NUM_LIT:1> <EOL> return ret <EOL> @ property <EOL> def reports_by_state ( self ) : <EOL> ret = { } <EOL> for state in Report . states : <EOL> ret [ state ] = Report . query . filter ( Report . state == state ) . count ( ) <EOL> return ret <EOL> @ property <EOL> def visits_by_action ( self ) : <EOL> ret = { } <EOL> for action in Visit . actions : <EOL> ret [ action ] = Visit . query . filter ( Visit . action == action ) . count ( ) <EOL> return ret </s>
