def get_count_stats(): day_ago = datetime.datetime.now() - datetime.timedelta(hours=24) week_ago = datetime.datetime.now() - datetime.timedelta(days=7) month_ago = datetime.datetime.now() - datetime.timedelta(days=30) incoming = { "today": ReceiveStatistic.select().where(ReceiveStatistic.created_at >= day_ago).count(), "week": ReceiveStatistic.select().where(ReceiveStatistic.created_at >= week_ago).count(), "month": ReceiveStatistic.select().where(ReceiveStatistic.created_at >= month_ago).count(), "all_time": ReceiveStatistic.select().count(), } outgoing = { "today": WorkerReceiveStatistic.select().where(WorkerReceiveStatistic.created_at >= day_ago).count(), "week": WorkerReceiveStatistic.select().where(WorkerReceiveStatistic.created_at >= week_ago).count(), "month": WorkerReceiveStatistic.select().where(WorkerReceiveStatistic.created_at >= month_ago).count(), "all_time": WorkerReceiveStatistic.select().count(), } distinct_nodes = { "all": Node.select().count(), "https": Node.select().where(Node.https==True).count(), } processing = { "workers": get_worker_count(), "queue_jobs": len(public_queue), } return incoming, outgoing, distinct_nodes, processing
def test_send_payload_stores_unknown_node_into_db(self, mock_handle_receive, mock_send_payload, mock_pod_preferences): process(Mock()) assert Node.select().count() == 1 node = Node.get(Node.host=="sub.example.com") assert node assert node.https
def test_send_payload_stores_unknown_node_into_db(self, mock_handle_receive, mock_send_document, mock_pod_preferences): process(Mock()) assert Node.select().count() == 1 node = Node.get(Node.host == "sub.example.com") assert node assert node.https
def get_count_stats(): day_ago = datetime.datetime.now() - datetime.timedelta(hours=24) week_ago = datetime.datetime.now() - datetime.timedelta(days=7) month_ago = datetime.datetime.now() - datetime.timedelta(days=30) incoming = { "today": ReceiveStatistic.select().where( ReceiveStatistic.created_at >= day_ago).count(), "week": ReceiveStatistic.select().where( ReceiveStatistic.created_at >= week_ago).count(), "month": ReceiveStatistic.select().where( ReceiveStatistic.created_at >= month_ago).count(), "all_time": ReceiveStatistic.select().count(), } outgoing = { "today": WorkerReceiveStatistic.select().where( WorkerReceiveStatistic.created_at >= day_ago).count(), "week": WorkerReceiveStatistic.select().where( WorkerReceiveStatistic.created_at >= week_ago).count(), "month": WorkerReceiveStatistic.select().where( WorkerReceiveStatistic.created_at >= month_ago).count(), "all_time": WorkerReceiveStatistic.select().count(), } distinct_nodes = { "all": Node.select().count(), "https": Node.select().where(Node.https == True).count(), } processing = { "workers": get_worker_count(), "queue_jobs": len(public_queue), } return incoming, outgoing, distinct_nodes, processing