def handle_flow_data_request(dbcc, msg): err.log_error(err.INFO, "Found a request for flow data") end_date_time = datetime.datetime.combine(msg.start_date, msg.start_time) + datetime.timedelta(seconds=msg.time_span) start_time_unix_ms = support.to_unix_timestamp_ms_from_date_and_time(msg.start_date, msg.start_time) stop_time_unix_ms = support.to_unix_timestamp_ms_from_date_and_time(end_date_time.date(), end_date_time.time()) db_flow_data_objects = test_db_layout.MaaSFlowData.retrieve_flow_data(dbcc, msg.link_id, start_time_unix_ms, stop_time_unix_ms) err.log_error(err.INFO, "Sending " + str(len(db_flow_data_objects)) + " rows of flow data") return test_db_layout.MaaSFlowData.construct_maas_single_link_answer(msg.link_id, db_flow_data_objects)
def test_to_unix_timestamp_ms_from_date_and_time(): t = datetime.time(hour=12, minute=30, second=10, microsecond=6000) d = datetime.date(year=1991, month=10, day=17) unix_ms = support.to_unix_timestamp_ms_from_date_and_time(d, t) run_tests.compare_answer(unix_ms, 687702610006, "")
def handle_flow_data_request(dbcc, msg): err.log_error(err.INFO, "Found a request for flow data") end_date_time = datetime.datetime.combine( msg.start_date, msg.start_time) + datetime.timedelta(seconds=msg.time_span) start_time_unix_ms = support.to_unix_timestamp_ms_from_date_and_time( msg.start_date, msg.start_time) stop_time_unix_ms = support.to_unix_timestamp_ms_from_date_and_time( end_date_time.date(), end_date_time.time()) db_flow_data_objects = test_db_layout.MaaSFlowData.retrieve_flow_data( dbcc, msg.link_id, start_time_unix_ms, stop_time_unix_ms) err.log_error( err.INFO, "Sending " + str(len(db_flow_data_objects)) + " rows of flow data") return test_db_layout.MaaSFlowData.construct_maas_single_link_answer( msg.link_id, db_flow_data_objects)