예제 #1
0
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
예제 #2
0
 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
예제 #3
0
 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
예제 #4
0
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