def show(): db_logic = flask.g.db_logic metric_names = db_logic.get_metric_ids() today = datetime.datetime.today() today_timestamp = to_timestamp(today) offsets = [(time_name, to_timestamp(today - offset)) for (time_name, offset) in DATE_NAMES_TO_TIMEDELTAS] current_values = db_logic.get_metrics_for_sha(db_logic.get_latest_sha()) metric_data = { time_name: db_logic.get_metrics_for_sha(db_logic.get_sha_for_date(timestamp)) for (time_name, timestamp) in offsets } return render_template( 'index.mako', groups=format_groups( flask.g.config, metric_names, today_timestamp, offsets, current_values, metric_data, ), )
def show(): metric_names = logic.get_metric_ids_from_database() today = datetime.datetime.today() today_timestamp = to_timestamp(today) offsets = [ (time_name, to_timestamp(today - offset)) for (time_name, offset) in DATE_NAMES_TO_TIMEDELTAS ] current_values = logic.get_metrics_for_sha(logic.get_latest_sha()) metric_data = dict( ( time_name, logic.get_metrics_for_sha(logic.get_sha_for_date(timestamp)), ) for (time_name, timestamp) in offsets ) return render_template( 'index.mako', groups=format_groups( metric_names, today_timestamp, offsets, current_values, metric_data, ), )
def all_data(metric_name): earliest_timestamp = logic.get_first_data_timestamp(metric_name) now = datetime.datetime.today() return flask.redirect(flask.url_for( 'graph.show', metric_name=metric_name, start=str(earliest_timestamp), end=str(to_timestamp(now)), ))
def show(): metric_names = logic.get_metric_ids_from_database() today = datetime.datetime.today() today_timestamp = to_timestamp(today) offsets = [(time_name, to_timestamp(today - offset)) for (time_name, offset) in DATE_NAMES_TO_TIMEDELTAS] current_values = logic.get_metrics_for_sha(logic.get_latest_sha()) metric_data = dict(( time_name, logic.get_metrics_for_sha(logic.get_sha_for_date(timestamp)), ) for (time_name, timestamp) in offsets) return render_template( 'index.mako', groups=format_groups( metric_names, today_timestamp, offsets, current_values, metric_data, ), )
def test_to_timestamp(): dt = datetime.datetime(2013, 1, 2, 3, 4, 5) ret = to_timestamp(dt) assert ret == 1357095845