def send_response(self, res_type_info): """Presents nice recent statistics. It preloads data in the template for maximum responsiveness and interactively fetches data from the JSON API. """ # Preloads the data to save a complete request. resolution = self.request.params.get('resolution', 'hours') if resolution not in stats_framework.RESOLUTIONS: self.abort(404) duration = utils.get_request_as_int(self.request, 'duration', default=120, min_value=1, max_value=1000) now = utils.get_request_as_datetime(self.request, 'now') now = now or datetime.datetime.utcnow() description = res_type_info.DESCRIPTION.copy() description.update( stats_framework_gviz.get_description_key(resolution)) stats_data = stats_framework.get_stats(stats.STATS_HANDLER, resolution, now, duration, False) template_data = self.process_data(description, stats_data) template_data['duration'] = duration template_data['now'] = now template_data['resolution'] = resolution self.response.write( template.render(res_type_info.TEMPLATE, template_data))
def get(self): """Presents nice recent statistics. It fetches data from the 'JSON' API. """ # Preloads the data to save a complete request. resolution = self.request.params.get('resolution', 'hours') if resolution not in ('days', 'hours', 'minutes'): resolution = 'hours' duration = utils.get_request_as_int(self.request, 'duration', 120, 1, 1000) description = _GVIZ_DESCRIPTION.copy() description.update( stats_framework_gviz.get_description_key(resolution)) table = stats_framework.get_stats(stats.STATS_HANDLER, resolution, None, duration, True) params = { 'duration': duration, 'initial_data': gviz_api.DataTable( description, table).ToJSon(columns_order=_GVIZ_COLUMNS_ORDER), 'now': datetime.datetime.utcnow(), 'resolution': resolution, } self.response.write(template.render('isolate/stats.html', params))
def get(self): description = _GVIZ_DESCRIPTION.copy() description.update( stats_framework_gviz.get_description_key(self.RESOLUTION)) try: stats_framework_gviz.get_json(self.request, self.response, stats.STATS_HANDLER, self.RESOLUTION, description, _GVIZ_COLUMNS_ORDER) except ValueError as e: self.abort(400, str(e))
def get(self): description = _GVIZ_DESCRIPTION.copy() description.update( stats_framework_gviz.get_description_key(self.RESOLUTION)) try: stats_framework_gviz.get_json( self.request, self.response, stats.STATS_HANDLER, self.RESOLUTION, description, _GVIZ_COLUMNS_ORDER) except ValueError as e: self.abort(400, str(e))
def send_response(self, res_type_info, resolution): if resolution not in stats_framework.RESOLUTIONS: self.abort(404) duration = utils.get_request_as_int(self.request, "duration", default=120, min_value=1, max_value=1000) now = utils.get_request_as_datetime(self.request, "now") description = res_type_info.DESCRIPTION.copy() description.update(stats_framework_gviz.get_description_key(resolution)) stats_data = stats_framework.get_stats(stats.STATS_HANDLER, resolution, now, duration, False) tqx_args = tqx_args = stats_framework_gviz.process_tqx(self.request.params.get("tqx", "")) try: stats_framework_gviz.get_json_raw( self.request, self.response, self.get_table(stats_data), description, res_type_info.ORDER, tqx_args ) except ValueError as e: self.abort(400, str(e))
def get(self): """Presents nice recent statistics. It fetches data from the 'JSON' API. """ # Preloads the data to save a complete request. resolution = self.request.params.get('resolution', 'hours') duration = utils.get_request_as_int(self.request, 'duration', 120, 1, 1000) description = _GVIZ_DESCRIPTION.copy() description.update(stats_framework_gviz.get_description_key(resolution)) table = stats_framework.get_stats( stats.STATS_HANDLER, resolution, None, duration, True) params = { 'duration': duration, 'initial_data': gviz_api.DataTable(description, table).ToJSon( columns_order=_GVIZ_COLUMNS_ORDER), 'now': datetime.datetime.utcnow(), 'resolution': resolution, } self.response.write(template.render('isolate/stats.html', params))
def send_response(self, res_type_info): """Presents nice recent statistics. It preloads data in the template for maximum responsiveness and interactively fetches data from the JSON API. """ # Preloads the data to save a complete request. resolution = self.request.params.get("resolution", "hours") if resolution not in stats_framework.RESOLUTIONS: self.abort(404) duration = utils.get_request_as_int(self.request, "duration", default=120, min_value=1, max_value=1000) now = utils.get_request_as_datetime(self.request, "now") now = now or datetime.datetime.utcnow() description = res_type_info.DESCRIPTION.copy() description.update(stats_framework_gviz.get_description_key(resolution)) stats_data = stats_framework.get_stats(stats.STATS_HANDLER, resolution, now, duration, False) template_data = self.process_data(description, stats_data) template_data["duration"] = duration template_data["now"] = now template_data["resolution"] = resolution self.response.write(template.render(res_type_info.TEMPLATE, template_data))
def send_response(self, res_type_info, resolution): if resolution not in stats_framework.RESOLUTIONS: self.abort(404) duration = utils.get_request_as_int(self.request, 'duration', default=120, min_value=1, max_value=1000) now = utils.get_request_as_datetime(self.request, 'now') description = res_type_info.DESCRIPTION.copy() description.update( stats_framework_gviz.get_description_key(resolution)) stats_data = stats_framework.get_stats(stats.STATS_HANDLER, resolution, now, duration, False) tqx_args = tqx_args = stats_framework_gviz.process_tqx( self.request.params.get('tqx', '')) try: stats_framework_gviz.get_json_raw(self.request, self.response, self.get_table(stats_data), description, res_type_info.ORDER, tqx_args) except ValueError as e: self.abort(400, str(e))