コード例 #1
0
ファイル: statistics.py プロジェクト: dmorley/social-relay
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
ファイル: test_workers.py プロジェクト: dmorley/social-relay
 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
ファイル: statistics.py プロジェクト: royalterra/social-relay
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