mirror of
https://github.com/lnbits/lnbits.git
synced 2025-03-17 21:31:55 +01:00
handle correctly the case with no active channels
This commit is contained in:
parent
10fb35b47f
commit
7306df3445
@ -68,13 +68,22 @@ class ChannelStats(BaseModel):
|
||||
if channel.state == ChannelState.ACTIVE
|
||||
]
|
||||
|
||||
return cls(
|
||||
counts=counts,
|
||||
avg_size=int(sum(active_channel_sizes) / len(active_channel_sizes)),
|
||||
biggest_size=max(active_channel_sizes),
|
||||
smallest_size=min(active_channel_sizes),
|
||||
total_capacity=sum(active_channel_sizes),
|
||||
)
|
||||
if len(active_channel_sizes) > 0:
|
||||
return cls(
|
||||
counts=counts,
|
||||
avg_size=int(sum(active_channel_sizes) / len(active_channel_sizes)),
|
||||
biggest_size=max(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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user