Skip to content

Commit

Permalink
Fix node status (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
DollyVolley authored Apr 23, 2021
1 parent bf10072 commit 5f73b88
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions bot/constants/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
# Emojis
# Be aware that keys of STATUS_EMOJIS are displayed to the user
STATUS_EMOJIS = {
"unknown": "❓",
"whitelisted": "📋",
"standby": "📆",
"ready": "✔️",
"active": "💚",
"disabled": "🔴"
"Unknown": "❓",
"Whitelisted": "📋",
"Standby": "📆",
"Ready": "✔️",
"Active": "💚",
"Disabled": "🔴"
}

HEALTH_EMOJIS = {
Expand Down
8 changes: 4 additions & 4 deletions bot/handlers/network_info_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,28 @@ async def show_network_stats(update, context):
validators = get_node_accounts()

statuses_counter = Counter(map(lambda v: v['status'], validators))
active_validators = filter(lambda v: v['status'] == 'active',
active_validators = filter(lambda v: v['status'] == 'Active',
validators)
versions_counter = Counter(
map(lambda v: v['version'], active_validators))

text += "\n📡 Nodes:\n"
for status in statuses_counter:
emoji = STATUS_EMOJIS[
status] if status in STATUS_EMOJIS else STATUS_EMOJIS["unknown"]
status] if status in STATUS_EMOJIS else STATUS_EMOJIS["Unknown"]
text += f" *{str(statuses_counter[status])}* ({status} {emoji})\n"

total_nodes = len(validators)
text += f" = *{str(total_nodes)}* (total)\n"

text += "\n" + STATUS_EMOJIS["active"] + " Active Bonds:\n *" + \
text += "\n" + STATUS_EMOJIS["Active"] + " Active Bonds:\n *" + \
tor_to_rune(network['bondMetrics']['totalActiveBond']) + "* (total)\n *" + \
tor_to_rune(network['bondMetrics']['averageActiveBond']) + "* (avg)\n *" + \
tor_to_rune(network['bondMetrics']['medianActiveBond']) + "* (median)\n *" + \
tor_to_rune(network['bondMetrics']['maximumActiveBond']) + "* (max)\n *" + \
tor_to_rune(network['bondMetrics']['minimumActiveBond']) + "* (min)\n"

text += "\n" + STATUS_EMOJIS["standby"] + " Standby Bonds:\n *" + \
text += "\n" + STATUS_EMOJIS["Standby"] + " Standby Bonds:\n *" + \
tor_to_rune(network['bondMetrics']['totalStandbyBond']) + "* (total)\n *" + \
tor_to_rune(network['bondMetrics']['averageStandbyBond']) + "* (avg)\n *" + \
tor_to_rune(network['bondMetrics']['medianStandbyBond']) + "* (median)\n *" + \
Expand Down
2 changes: 1 addition & 1 deletion bot/handlers/thornodes_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def get_thornode_menu_buttons(chat_data):
buttons = []
for address in chat_data.get('nodes', {}).keys():
node = chat_data['nodes'][address]
status_emoji = STATUS_EMOJIS.get(node['status'], STATUS_EMOJIS["unknown"])
status_emoji = STATUS_EMOJIS.get(node['status'], STATUS_EMOJIS["Unknown"])
truncated_address = f"...{address[-3:]}"
is_catching_up = node.get('is_catching_up', None)
is_healthy = None if is_catching_up is None else not is_catching_up
Expand Down

0 comments on commit 5f73b88

Please sign in to comment.