def index(request): account_amount = ModelAccount.objects.count() char_amount = ModelCharacter.objects.count() total_purchase = ModelPurchase.objects.aggregate(Sum('fee'))['fee__sum'] if not total_purchase: total_purchase = 0 server_info = [] for s in ModelServer.opened_servers(): this_total_purchase = ModelPurchase.objects.filter(server_id=s.id).aggregate(Sum('fee'))['fee__sum'] if not this_total_purchase: this_total_purchase = 0 info = { 'sid': s.id, 'server_name': s.name, 'opened_at': arrow.get(s.open_at).to(settings.TIME_ZONE).format("YYYY-MM-DD HH:mm:ss"), 'char_amount': ModelCharacter.objects.filter(server_id=s.id).count(), 'total_purchase': this_total_purchase } server_info.append(info) context = { 'current': 'index', 'account_amount': account_amount, 'char_amount': char_amount, 'total_purchase': total_purchase, 'server_info': server_info } return render_to_response( 'dianjing_statistics_index.html', context=context )
def get_server_list(request): account_id = request._game_session.account_id servers = Server.opened_servers() response = GetServerListResponse() response.ret = 0 recommend_id = 0 max_id = 0 for server in servers: s = response.servers.add() s.id = server.id s.name = server.name s.status = server.status s.is_new = server.is_new if server.recommend: recommend_id = server.id if server.id > max_id: max_id = server.id if not recommend_id: recommend_id = max_id response.recommend_id = recommend_id recent_server_ids = AccountLoginLog.get_account_recent_server_ids(account_id) response.recent_ids.extend(recent_server_ids) return ProtobufResponse(response)
def get_server_list(request): account_id = request._game_session.account_id servers = Server.opened_servers() response = GetServerListResponse() response.ret = 0 recommend_id = 0 max_id = 0 for server in servers: s = response.servers.add() s.id = server.id s.name = server.name s.status = server.status s.is_new = server.is_new if server.recommend: recommend_id = server.id if server.id > max_id: max_id = server.id if not recommend_id: recommend_id = max_id response.recommend_id = recommend_id recent_server_ids = AccountLoginLog.get_account_recent_server_ids( account_id) response.recent_ids.extend(recent_server_ids) return ProtobufResponse(response)
def get_servers_select_context(show_all=False): if show_all: servers_select = [{'display': '全部', 'value': 0}] else: servers_select = [] for s in ModelServer.opened_servers(): servers_select.append({'display': s.id, 'value': s.id}) return servers_select