mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-22 15:57:28 +02:00
handle correctly the case with no active channels
This commit is contained in:
@@ -68,13 +68,22 @@ class ChannelStats(BaseModel):
|
|||||||
if channel.state == ChannelState.ACTIVE
|
if channel.state == ChannelState.ACTIVE
|
||||||
]
|
]
|
||||||
|
|
||||||
return cls(
|
if len(active_channel_sizes) > 0:
|
||||||
counts=counts,
|
return cls(
|
||||||
avg_size=int(sum(active_channel_sizes) / len(active_channel_sizes)),
|
counts=counts,
|
||||||
biggest_size=max(active_channel_sizes),
|
avg_size=int(sum(active_channel_sizes) / len(active_channel_sizes)),
|
||||||
smallest_size=min(active_channel_sizes),
|
biggest_size=max(active_channel_sizes),
|
||||||
total_capacity=sum(active_channel_sizes),
|
smallest_size=min(active_channel_sizes),
|
||||||
)
|
total_capacity=sum(active_channel_sizes),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return cls(
|
||||||
|
counts=counts,
|
||||||
|
avg_size=0,
|
||||||
|
biggest_size=0,
|
||||||
|
smallest_size=0,
|
||||||
|
total_capacity=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NodeFees(BaseModel):
|
class NodeFees(BaseModel):
|
||||||
|
Reference in New Issue
Block a user