Exemple #1
0
    def get(self, request):
        user_status = [
            NodeOnlineLog.get_all_node_online_user_count(),
            User.get_today_register_user().count(),
            UserCheckInLog.get_today_checkin_user_count(),
            User.get_never_used_user_count(),
        ]
        donate_status = [
            Donate.get_donate_count_by_date(),
            Donate.get_donate_money_by_date(),
            Donate.get_donate_count_by_date(date=pendulum.today()),
            Donate.get_donate_money_by_date(date=pendulum.today()),
        ]

        active_nodes = SSNode.get_active_nodes() + VmessNode.get_active_nodes()

        node_status = {
            "names": [node.name for node in active_nodes],
            "traffics": [
                round(node.used_traffic / settings.GB, 2) for node in active_nodes
            ],
        }
        data = {
            "user_status": user_status,
            "donate_status": donate_status,
            "node_status": node_status,
        }
        return JsonResponse(data)
    def get(self, request):
        today_register_user = User.get_today_register_user().values()[:10]
        # find inviter
        for u in today_register_user:
            try:
                u["inviter"] = User.objects.get(pk=u["inviter_id"])
            except User.DoesNotExist:
                u["inviter"] = "None"

        context = {
            "total_user_num":
            User.get_total_user_num(),
            "alive_user_count":
            NodeOnlineLog.get_all_node_online_user_count(),
            "today_checked_user_count":
            UserCheckInLog.get_today_checkin_user_count(),
            "today_register_user_count":
            len(today_register_user),
            "traffic_users":
            UserTraffic.get_user_order_by_traffic(count=10),
            "rich_users_data":
            Donate.get_most_donated_user_by_count(10),
            "today_register_user":
            today_register_user,
        }
        return render(request, "my_admin/user_status.html", context=context)
Exemple #3
0
def userData(request):
    '''
    返回用户信息:
    在线人数、今日签到、从未签到、从未使用
    '''

    data = [
        NodeOnlineLog.totalOnlineUser(),
        User.get_today_register_user().count(),
        Suser.get_today_checked_user_num(),
        Suser.get_never_checked_user_num(),
        Suser.get_never_used_num(),
    ]
    return JsonResponse({'data': data})