feat(status): show money-supply metric in /status
Adds economy.get_economy_stats() (single-scan total coins, house balance, player-held coins, player count) and a "Rahavaru" field to /status, so admins can see whether the sinks are keeping pace with minted income. Also removed a duplicate bot_admin_check import. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VbAVsrZuYesea99mPMmPT
This commit is contained in:
@@ -47,3 +47,31 @@ class TestGetAllLeaderboards:
|
||||
fish = run(economy.get_all_leaderboards())["fish"]
|
||||
counts = [c for _, c in fish]
|
||||
assert counts == sorted(counts, reverse=True)
|
||||
|
||||
|
||||
class TestEconomyStats:
|
||||
def test_totals_split_house_from_players(self, fake_pb, monkeypatch):
|
||||
monkeypatch.setattr(economy.house, "HOUSE_ID", 999)
|
||||
monkeypatch.setattr(economy.house, "_house_pb_id", None)
|
||||
# three players + the house
|
||||
for uid, bal in [(1, 100), (2, 250), (3, 0)]:
|
||||
run(economy.get_user(uid))
|
||||
fake_pb.record_for(uid)["balance"] = bal
|
||||
run(economy.get_user(999))
|
||||
fake_pb.record_for(999)["balance"] = 5000
|
||||
|
||||
stats = run(economy.get_economy_stats())
|
||||
assert stats["total_coins"] == 100 + 250 + 0 + 5000
|
||||
assert stats["house_balance"] == 5000
|
||||
assert stats["player_coins"] == 350
|
||||
assert stats["player_count"] == 3 # house excluded
|
||||
|
||||
def test_no_house_configured(self, fake_pb, monkeypatch):
|
||||
monkeypatch.setattr(economy.house, "HOUSE_ID", None)
|
||||
run(economy.get_user(1))
|
||||
fake_pb.record_for(1)["balance"] = 42
|
||||
stats = run(economy.get_economy_stats())
|
||||
assert stats["total_coins"] == 42
|
||||
assert stats["house_balance"] == 0
|
||||
assert stats["player_coins"] == 42
|
||||
assert stats["player_count"] == 1
|
||||
|
||||
Reference in New Issue
Block a user