Use typeclass-family instead of location/destination for object stats. Resolve #1845
This commit is contained in:
parent
94918c8b72
commit
3ef51823d6
2 changed files with 23 additions and 16 deletions
|
|
@ -436,20 +436,25 @@ class CmdObjects(COMMAND_DEFAULT_CLASS):
|
||||||
caller = self.caller
|
caller = self.caller
|
||||||
nlim = int(self.args) if self.args and self.args.isdigit() else 10
|
nlim = int(self.args) if self.args and self.args.isdigit() else 10
|
||||||
nobjs = ObjectDB.objects.count()
|
nobjs = ObjectDB.objects.count()
|
||||||
base_char_typeclass = settings.BASE_CHARACTER_TYPECLASS
|
Character = class_from_module(settings.BASE_CHARACTER_TYPECLASS)
|
||||||
nchars = ObjectDB.objects.filter(db_typeclass_path=base_char_typeclass).count()
|
nchars = Character.objects.all_family().count()
|
||||||
nrooms = ObjectDB.objects.filter(db_location__isnull=True).exclude(
|
Room = class_from_module(settings.BASE_ROOM_TYPECLASS)
|
||||||
db_typeclass_path=base_char_typeclass).count()
|
nrooms = Room.objects.all_family().count()
|
||||||
nexits = ObjectDB.objects.filter(db_location__isnull=False, db_destination__isnull=False).count()
|
Exit = class_from_module(settings.BASE_EXIT_TYPECLASS)
|
||||||
|
nexits = Exit.objects.all_family().count()
|
||||||
nother = nobjs - nchars - nrooms - nexits
|
nother = nobjs - nchars - nrooms - nexits
|
||||||
nobjs = nobjs or 1 # fix zero-div error with empty database
|
nobjs = nobjs or 1 # fix zero-div error with empty database
|
||||||
|
|
||||||
# total object sum table
|
# total object sum table
|
||||||
totaltable = self.style_table("|wtype|n", "|wcomment|n", "|wcount|n", "|w%%|n", border="table", align="l")
|
totaltable = self.style_table("|wtype|n", "|wcomment|n", "|wcount|n", "|w%%|n",
|
||||||
|
border="table", align="l")
|
||||||
totaltable.align = 'l'
|
totaltable.align = 'l'
|
||||||
totaltable.add_row("Characters", "(BASE_CHARACTER_TYPECLASS)", nchars, "%.2f" % ((float(nchars) / nobjs) * 100))
|
totaltable.add_row("Characters", "(BASE_CHARACTER_TYPECLASS + children)",
|
||||||
totaltable.add_row("Rooms", "(location=None)", nrooms, "%.2f" % ((float(nrooms) / nobjs) * 100))
|
nchars, "%.2f" % ((float(nchars) / nobjs) * 100))
|
||||||
totaltable.add_row("Exits", "(destination!=None)", nexits, "%.2f" % ((float(nexits) / nobjs) * 100))
|
totaltable.add_row("Rooms", "(BASE_ROOM_TYPECKLASS + children)",
|
||||||
|
nrooms, "%.2f" % ((float(nrooms) / nobjs) * 100))
|
||||||
|
totaltable.add_row("Exits", "(BASE_EXIT_TYPECLASS + children)",
|
||||||
|
nexits, "%.2f" % ((float(nexits) / nobjs) * 100))
|
||||||
totaltable.add_row("Other", "", nother, "%.2f" % ((float(nother) / nobjs) * 100))
|
totaltable.add_row("Other", "", nother, "%.2f" % ((float(nother) / nobjs) * 100))
|
||||||
|
|
||||||
# typeclass table
|
# typeclass table
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,15 @@ def _gamestats():
|
||||||
nsess = SESSION_HANDLER.account_count()
|
nsess = SESSION_HANDLER.account_count()
|
||||||
# nsess = len(AccountDB.objects.get_connected_accounts()) or "no one"
|
# nsess = len(AccountDB.objects.get_connected_accounts()) or "no one"
|
||||||
|
|
||||||
nobjs = ObjectDB.objects.all().count()
|
nobjs = ObjectDB.objects.count()
|
||||||
nrooms = ObjectDB.objects.filter(
|
nobjs = nobjs or 1 # fix zero-div error with empty database
|
||||||
db_location__isnull=True).exclude(db_typeclass_path=_BASE_CHAR_TYPECLASS).count()
|
Character = class_from_module(settings.BASE_CHARACTER_TYPECLASS)
|
||||||
nexits = ObjectDB.objects.filter(
|
nchars = Character.objects.all_family().count()
|
||||||
db_location__isnull=False, db_destination__isnull=False).count()
|
Room = class_from_module(settings.BASE_ROOM_TYPECLASS)
|
||||||
nchars = ObjectDB.objects.filter(db_typeclass_path=_BASE_CHAR_TYPECLASS).count()
|
nrooms = Room.objects.all_family().count()
|
||||||
nothers = nobjs - nrooms - nchars - nexits
|
Exit = class_from_module(settings.BASE_EXIT_TYPECLASS)
|
||||||
|
nexits = Exit.objects.all_family().count()
|
||||||
|
nothers = nobjs - nchars - nrooms - nexits
|
||||||
|
|
||||||
pagevars = {
|
pagevars = {
|
||||||
"page_title": "Front Page",
|
"page_title": "Front Page",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue