def _gamestats(): # Some misc. configurable stuff. # TODO: Move this to either SQL or settings.py based configuration. fpage_account_limit = 4 # A QuerySet of the most recently connected accounts. recent_users = AccountDB.objects.get_recently_connected_accounts()[:fpage_account_limit] nplyrs_conn_recent = len(recent_users) nplyrs = AccountDB.objects.num_total_accounts() nplyrs_reg_recent = len(AccountDB.objects.get_recently_created_accounts()) nsess = SESSION_HANDLER.account_count() # nsess = len(AccountDB.objects.get_connected_accounts()) or "no one" nobjs = ObjectDB.objects.all().count() nrooms = ObjectDB.objects.filter(db_location__isnull=True).exclude(db_typeclass_path=_BASE_CHAR_TYPECLASS).count() nexits = ObjectDB.objects.filter(db_location__isnull=False, db_destination__isnull=False).count() nchars = ObjectDB.objects.filter(db_typeclass_path=_BASE_CHAR_TYPECLASS).count() nothers = nobjs - nrooms - nchars - nexits pagevars = { "page_title": "Front Page", "players_connected_recent": recent_users, "num_players_connected": nsess, "num_players_registered": nplyrs, "num_players_connected_recent": nplyrs_conn_recent, "num_players_registered_recent": nplyrs_reg_recent, "num_rooms": nrooms, "num_exits": nexits, "num_objects": nobjs, "num_characters": nchars, "num_others": nothers } return pagevars
def _gamestats(): # Some misc. configurable stuff. # TODO: Move this to either SQL or settings.py based configuration. fpage_account_limit = 8 # A QuerySet of the most recently connected accounts. recent_users = AccountDB.objects.get_recently_connected_accounts( )[:fpage_account_limit] current_users = AccountDB.objects.get_connected_accounts() current_chars = [] for element in current_users: grid_char = element.puppet current_chars.append(grid_char.key if grid_char else '*ghost*') nplyrs_conn_recent = len(recent_users) or "none" nplyrs = AccountDB.objects.num_total_accounts() or "none" nplyrs_reg_recent = len( AccountDB.objects.get_recently_created_accounts()) or "none" nsess = SESSION_HANDLER.account_count() # nsess = len(PlayerDB.objects.get_connected_players()) or "no one" nobjs = ObjectDB.objects.all().count() nrooms = ObjectDB.objects.filter(db_location__isnull=True).exclude( db_typeclass_path=_BASE_CHAR_TYPECLASS).count() nexits = ObjectDB.objects.filter(db_location__isnull=False, db_destination__isnull=False).count() nchars = ObjectDB.objects.filter( db_typeclass_path=_BASE_CHAR_TYPECLASS).count() nothers = nobjs - nrooms - nchars - nexits pagevars = { "page_title": "Front Page", "accounts_connected_recent": recent_users, "accounts_connected_now": current_users, "characters_on_grid": current_chars, "num_accounts_connected": nsess or "no one", "num_accounts_registered": nplyrs or "no", "num_accounts_connected_recent": nplyrs_conn_recent or "no", "num_accounts_registered_recent": nplyrs_reg_recent or "no one", "num_rooms": nrooms or "none", "num_exits": nexits or "no", "num_objects": nobjs or "none", "num_characters": nchars or "no", "num_others": nothers or "no" } return pagevars
def _gamestats(): # Some misc. configurable stuff. # TODO: Move this to either SQL or settings.py based configuration. fpage_account_limit = 4 # A QuerySet of the most recently connected accounts. recent_users = AccountDB.objects.get_recently_connected_accounts( )[:fpage_account_limit] nplyrs_conn_recent = len(recent_users) or "none" nplyrs = AccountDB.objects.num_total_accounts() or "none" nplyrs_reg_recent = len( AccountDB.objects.get_recently_created_accounts()) or "none" nsess = SESSION_HANDLER.account_count() # nsess = len(AccountDB.objects.get_connected_accounts()) or "no one" nobjs = ObjectDB.objects.count() nobjs = nobjs or 1 # fix zero-div error with empty database Character = class_from_module( settings.BASE_CHARACTER_TYPECLASS, fallback=settings.FALLBACK_CHARACTER_TYPECLASS) nchars = Character.objects.all_family().count() Room = class_from_module(settings.BASE_ROOM_TYPECLASS, fallback=settings.FALLBACK_ROOM_TYPECLASS) nrooms = Room.objects.all_family().count() Exit = class_from_module(settings.BASE_EXIT_TYPECLASS, fallback=settings.FALLBACK_EXIT_TYPECLASS) nexits = Exit.objects.all_family().count() nothers = nobjs - nchars - nrooms - nexits pagevars = { "page_title": "Front Page", "accounts_connected_recent": recent_users, "num_accounts_connected": nsess or "no one", "num_accounts_registered": nplyrs or "no", "num_accounts_connected_recent": nplyrs_conn_recent or "no", "num_accounts_registered_recent": nplyrs_reg_recent or "no one", "num_rooms": nrooms or "none", "num_exits": nexits or "no", "num_objects": nobjs or "none", "num_characters": nchars or "no", "num_others": nothers or "no", } return pagevars
def _gamestats(): # Some misc. configurable stuff. # TODO: Move this to either SQL or settings.py based configuration. fpage_account_limit = 8 # A QuerySet of the most recently connected accounts. recent_users = AccountDB.objects.get_recently_connected_accounts()[:fpage_account_limit] current_users = AccountDB.objects.get_connected_accounts() current_chars = [] for element in current_users: grid_char = element.puppet current_chars.append(grid_char.key if grid_char else '*ghost*') nplyrs_conn_recent = len(recent_users) or "none" nplyrs = AccountDB.objects.num_total_accounts() or "none" nplyrs_reg_recent = len(AccountDB.objects.get_recently_created_accounts()) or "none" nsess = SESSION_HANDLER.account_count() # nsess = len(PlayerDB.objects.get_connected_players()) or "no one" nobjs = ObjectDB.objects.all().count() nrooms = ObjectDB.objects.filter(db_location__isnull=True).exclude(db_typeclass_path=_BASE_CHAR_TYPECLASS).count() nexits = ObjectDB.objects.filter(db_location__isnull=False, db_destination__isnull=False).count() nchars = ObjectDB.objects.filter(db_typeclass_path=_BASE_CHAR_TYPECLASS).count() nothers = nobjs - nrooms - nchars - nexits pagevars = { "page_title": "Front Page", "accounts_connected_recent": recent_users, "accounts_connected_now": current_users, "characters_on_grid": current_chars, "num_accounts_connected": nsess or "no one", "num_accounts_registered": nplyrs or "no", "num_accounts_connected_recent": nplyrs_conn_recent or "no", "num_accounts_registered_recent": nplyrs_reg_recent or "no one", "num_rooms": nrooms or "none", "num_exits": nexits or "no", "num_objects": nobjs or "none", "num_characters": nchars or "no", "num_others": nothers or "no" } return pagevars