def run(self): with session_scope() as db_session: update_last_accessed(db_session, endpoint_name=self._endpoint.name) add_request(db_session, duration=self._duration, endpoint_id=self._endpoint.id, ip=self._ip)
def _on_thread_stopped(self): with session_scope() as db_session: update_last_accessed(db_session, endpoint_name=self._endpoint.name) request_id = add_request(db_session, duration=self._duration, endpoint_id=self._endpoint.id, ip=self._ip) self._lines_body = order_histogram(self._histogram.items()) self.insert_lines_db(db_session, request_id) if self._outlier_profiler: self._outlier_profiler.add_outlier(request_id)
def test_update_last_accessed(self): """ Test whether the function returns the right values. """ import datetime time = datetime.datetime.now() from flask_monitoringdashboard.database.endpoint import update_last_accessed, get_last_accessed_times update_last_accessed(NAME, time) result = get_last_accessed_times() self.assertEqual(len(result), 1) self.assertEqual(result[0].endpoint, NAME) self.assertEqual(result[0].last_accessed, time)
def test_update_last_accessed(self): """ Test whether the function returns the right values. """ import datetime time = datetime.datetime.utcnow() from flask_monitoringdashboard.database.endpoint import update_last_accessed, get_last_requested from flask_monitoringdashboard.database.count_group import get_value with session_scope() as db_session: update_last_accessed(db_session, NAME) result = get_value(get_last_requested(db_session), NAME) result_utc = to_utc_datetime(result) self.assertTrue((result_utc - time).seconds < 1)
def run(self): with session_scope() as db_session: update_last_accessed(db_session, endpoint_name=self._endpoint.name)
def wrapper(*args, **kwargs): update_last_accessed(endpoint=endpoint, value=datetime.datetime.now()) return func(*args, **kwargs)