From 42aae726ff73ec605dfbdf2c4c27299d9589877d Mon Sep 17 00:00:00 2001 From: cryptosharks131 Date: Mon, 3 Apr 2023 23:08:52 -0400 Subject: [PATCH] Fix pandas v2 sum --- gui/templates/base.html | 2 +- gui/views.py | 66 ++++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/gui/templates/base.html b/gui/templates/base.html index d8c54742..ea6e07e3 100644 --- a/gui/templates/base.html +++ b/gui/templates/base.html @@ -43,7 +43,7 @@

My Lnd Overview

-
LNDg v1.6.0
+
LNDg v1.6.1
diff --git a/gui/views.py b/gui/views.py index 40726be3..0c8f12c7 100644 --- a/gui/views.py +++ b/gui/views.py @@ -167,12 +167,12 @@ def home(request): filter_1day = datetime.now() - timedelta(days=1) forwards_df_7d = DataFrame.from_records(forwards.filter(forward_date__gte=filter_7day).values()) forwards_df_1d = DataFrame() if forwards_df_7d.empty else forwards_df_7d[forwards_df_7d['forward_date']>=filter_1day] - forwards_df_in_7d_sum = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_in', as_index=True).sum() - forwards_df_out_7d_sum = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_out', as_index=True).sum() + forwards_df_in_7d_sum = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_in', as_index=True).sum(numeric_only=True) + forwards_df_out_7d_sum = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_out', as_index=True).sum(numeric_only=True) forwards_df_in_7d_count = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_in', as_index=True).count() forwards_df_out_7d_count = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_out', as_index=True).count() - forwards_df_in_1d_sum = DataFrame() if forwards_df_1d.empty else forwards_df_1d.groupby('chan_id_in', as_index=True).sum() - forwards_df_out_1d_sum = DataFrame() if forwards_df_1d.empty else forwards_df_1d.groupby('chan_id_out', as_index=True).sum() + forwards_df_in_1d_sum = DataFrame() if forwards_df_1d.empty else forwards_df_1d.groupby('chan_id_in', as_index=True).sum(numeric_only=True) + forwards_df_out_1d_sum = DataFrame() if forwards_df_1d.empty else forwards_df_1d.groupby('chan_id_out', as_index=True).sum(numeric_only=True) forwards_df_in_1d_count = DataFrame() if forwards_df_1d.empty else forwards_df_1d.groupby('chan_id_in', as_index=True).count() forwards_df_out_1d_count = DataFrame() if forwards_df_1d.empty else forwards_df_1d.groupby('chan_id_out', as_index=True).count() routed_1day = forwards_df_1d.shape[0] @@ -356,24 +356,24 @@ def channels(request): if channels_df.shape[0] > 0: forwards_df_30d = DataFrame.from_records(forwards.values()) forwards_df_7d = DataFrame.from_records(forwards.filter(forward_date__gte=filter_7day).values()) - forwards_df_in_30d_sum = DataFrame() if forwards_df_30d.empty else forwards_df_30d.groupby('chan_id_in', as_index=True).sum() - forwards_df_out_30d_sum = DataFrame() if forwards_df_30d.empty else forwards_df_30d.groupby('chan_id_out', as_index=True).sum() - forwards_df_in_7d_sum = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_in', as_index=True).sum() - forwards_df_out_7d_sum = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_out', as_index=True).sum() + forwards_df_in_30d_sum = DataFrame() if forwards_df_30d.empty else forwards_df_30d.groupby('chan_id_in', as_index=True).sum(numeric_only=True) + forwards_df_out_30d_sum = DataFrame() if forwards_df_30d.empty else forwards_df_30d.groupby('chan_id_out', as_index=True).sum(numeric_only=True) + forwards_df_in_7d_sum = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_in', as_index=True).sum(numeric_only=True) + forwards_df_out_7d_sum = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_out', as_index=True).sum(numeric_only=True) forwards_df_in_30d_count = DataFrame() if forwards_df_30d.empty else forwards_df_30d.groupby('chan_id_in', as_index=True).count() forwards_df_out_30d_count = DataFrame() if forwards_df_30d.empty else forwards_df_30d.groupby('chan_id_out', as_index=True).count() forwards_df_in_7d_count = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_in', as_index=True).count() forwards_df_out_7d_count = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_out', as_index=True).count() payments_df_30d = DataFrame.from_records(payments.values()) payments_df_7d = DataFrame.from_records(payments.filter(creation_date__gte=filter_7day).values()) - payments_df_30d_sum = DataFrame() if payments_df_30d.empty else payments_df_30d.groupby('chan_out', as_index=True).sum() - payments_df_7d_sum = DataFrame() if payments_df_7d.empty else payments_df_7d.groupby('chan_out', as_index=True).sum() + payments_df_30d_sum = DataFrame() if payments_df_30d.empty else payments_df_30d.groupby('chan_out', as_index=True).sum(numeric_only=True) + payments_df_7d_sum = DataFrame() if payments_df_7d.empty else payments_df_7d.groupby('chan_out', as_index=True).sum(numeric_only=True) payments_df_30d_count = DataFrame() if payments_df_30d.empty else payments_df_30d.groupby('chan_out', as_index=True).count() payments_df_7d_count = DataFrame() if payments_df_7d.empty else payments_df_7d.groupby('chan_out', as_index=True).count() invoices_df_30d = DataFrame.from_records(invoices.values()) invoices_df_7d = DataFrame.from_records(invoices.filter(settle_date__gte=filter_7day).values()) - invoices_df_30d_sum = DataFrame() if invoices_df_30d.empty else invoices_df_30d.groupby('chan_in', as_index=True).sum() - invoices_df_7d_sum = DataFrame() if invoices_df_7d.empty else invoices_df_7d.groupby('chan_in', as_index=True).sum() + invoices_df_30d_sum = DataFrame() if invoices_df_30d.empty else invoices_df_30d.groupby('chan_in', as_index=True).sum(numeric_only=True) + invoices_df_7d_sum = DataFrame() if invoices_df_7d.empty else invoices_df_7d.groupby('chan_in', as_index=True).sum(numeric_only=True) invoices_df_30d_count = DataFrame() if invoices_df_30d.empty else invoices_df_30d.groupby('chan_in', as_index=True).count() invoices_df_7d_count = DataFrame() if invoices_df_7d.empty else invoices_df_7d.groupby('chan_in', as_index=True).count() invoice_hashes_7d = DataFrame() if invoices_df_7d.empty else invoices_df_7d.groupby('chan_in', as_index=True)['r_hash'].apply(list) @@ -481,8 +481,8 @@ def fees(request): failed_htlc_df = failed_htlc_df[(failed_htlc_df['wire_failure']==15) & (failed_htlc_df['failure_detail']==6) & (failed_htlc_df['amount']>failed_htlc_df['chan_out_liq']+failed_htlc_df['chan_out_pending'])] forwards = Forwards.objects.filter(forward_date__gte=filter_7day, amt_out_msat__gte=1000000) forwards_df_7d = DataFrame.from_records(forwards.values()) - forwards_df_in_7d_sum = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_in', as_index=True).sum() - forwards_df_out_7d_sum = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_out', as_index=True).sum() + forwards_df_in_7d_sum = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_in', as_index=True).sum(numeric_only=True) + forwards_df_out_7d_sum = DataFrame() if forwards_df_7d.empty else forwards_df_7d.groupby('chan_id_out', as_index=True).sum(numeric_only=True) channels_df['local_balance'] = channels_df.apply(lambda row: row.local_balance + row.pending_outbound, axis=1) channels_df['remote_balance'] = channels_df.apply(lambda row: row.remote_balance + row.pending_inbound, axis=1) channels_df['in_percent'] = channels_df.apply(lambda row: int(round((row['remote_balance']/row['capacity'])*100, 0)), axis=1) @@ -498,7 +498,7 @@ def fees(request): invoices = Invoices.objects.filter(state=1).filter(settle_date__gte=filter_7day).filter(r_hash__in=payments.values_list('payment_hash')) payments_df_7d = DataFrame.from_records(payments.filter(creation_date__gte=filter_7day).values()) invoices_df_7d = DataFrame.from_records(invoices.filter(settle_date__gte=filter_7day).values()) - invoices_df_7d_sum = DataFrame() if invoices_df_7d.empty else invoices_df_7d.groupby('chan_in', as_index=True).sum() + invoices_df_7d_sum = DataFrame() if invoices_df_7d.empty else invoices_df_7d.groupby('chan_in', as_index=True).sum(numeric_only=True) invoice_hashes_7d = DataFrame() if invoices_df_7d.empty else invoices_df_7d.groupby('chan_in', as_index=True)['r_hash'].apply(list) channels_df['amt_rebal_in_7day'] = channels_df.apply(lambda row: int(invoices_df_7d_sum.loc[row.chan_id].amt_paid) if invoices_df_7d_sum.empty == False and (invoices_df_7d_sum.index == row.chan_id).any() else 0, axis=1) channels_df['costs_7day'] = channels_df.apply(lambda row: 0 if row['amt_rebal_in_7day'] == 0 else int(payments_df_7d.set_index('payment_hash', inplace=False).loc[invoice_hashes_7d[row.chan_id] if invoice_hashes_7d.empty == False and (invoice_hashes_7d.index == row.chan_id).any() else []]['fee'].sum()), axis=1) @@ -1119,7 +1119,7 @@ def channel(request): forwards_out_df = DataFrame() if forwards_in_df.shape[0]> 0: forwards_in_df_count = forwards_in_df.groupby('chan_id_in', as_index=True).count() - forwards_in_df_sum = forwards_in_df.groupby('chan_id_in', as_index=True).sum() + forwards_in_df_sum = forwards_in_df.groupby('chan_id_in', as_index=True).sum(numeric_only=True) channels_df['routed_in'] = forwards_in_df_count.loc[chan_id].amt_out_msat channels_df['amt_routed_in'] = int(forwards_in_df_sum.loc[chan_id].amt_out_msat/1000) channels_df['average_in'] = 0 if channels_df['routed_in'][0] == 0 else int(channels_df['amt_routed_in']/channels_df['routed_in']) @@ -1127,7 +1127,7 @@ def channel(request): forwards_in_df_30d = forwards_in_df.loc[forwards_in_df['forward_date'] >= filter_30day] if forwards_in_df_30d.shape[0] > 0: forwards_in_df_30d_count = forwards_in_df_30d.groupby('chan_id_in', as_index=True).count() - forwards_in_df_30d_sum = forwards_in_df_30d.groupby('chan_id_in', as_index=True).sum() + forwards_in_df_30d_sum = forwards_in_df_30d.groupby('chan_id_in', as_index=True).sum(numeric_only=True) channels_df['routed_in_30day'] = forwards_in_df_30d_count.loc[chan_id].amt_out_msat channels_df['amt_routed_in_30day'] = int(forwards_in_df_30d_sum.loc[chan_id].amt_out_msat/1000) channels_df['average_in_30day'] = 0 if channels_df['routed_in_30day'][0] == 0 else int(channels_df['amt_routed_in_30day']/channels_df['routed_in_30day']) @@ -1135,19 +1135,19 @@ def channel(request): forwards_in_df_7d = forwards_in_df_30d.loc[forwards_in_df_30d['forward_date'] >= filter_7day] if forwards_in_df_7d.shape[0] > 0: forwards_in_df_7d_count = forwards_in_df_7d.groupby('chan_id_in', as_index=True).count() - forwards_in_df_7d_sum = forwards_in_df_7d.groupby('chan_id_in', as_index=True).sum() + forwards_in_df_7d_sum = forwards_in_df_7d.groupby('chan_id_in', as_index=True).sum(numeric_only=True) channels_df['routed_in_7day'] = forwards_in_df_7d_count.loc[chan_id].amt_out_msat channels_df['amt_routed_in_7day'] = int(forwards_in_df_7d_sum.loc[chan_id].amt_out_msat/1000) channels_df['average_in_7day'] = 0 if channels_df['routed_in_7day'][0] == 0 else int(channels_df['amt_routed_in_7day']/channels_df['routed_in_7day']) channels_df['revenue_assist_7day'] = int(forwards_in_df_7d_sum.loc[chan_id].fee) - forwards_in_df_7d_sum = forwards_in_df_7d[forwards_in_df_7d['amt_out_msat']>=1000000].groupby('chan_id_in', as_index=True).sum() + forwards_in_df_7d_sum = forwards_in_df_7d[forwards_in_df_7d['amt_out_msat']>=1000000].groupby('chan_id_in', as_index=True).sum(numeric_only=True) if forwards_in_df_7d_sum.shape[0] > 0: channels_df['amt_routed_in_7day_fees'] = int(forwards_in_df_7d_sum.loc[chan_id].amt_out_msat/1000) channels_df['revenue_assist_7day_fees'] = int(forwards_in_df_7d_sum.loc[chan_id].fee) forwards_in_df_1d = forwards_in_df_7d.loc[forwards_in_df_7d['forward_date'] >= filter_1day] if forwards_in_df_1d.shape[0] > 0: forwards_in_df_1d_count = forwards_in_df_1d.groupby('chan_id_in', as_index=True).count() - forwards_in_df_1d_sum = forwards_in_df_1d.groupby('chan_id_in', as_index=True).sum() + forwards_in_df_1d_sum = forwards_in_df_1d.groupby('chan_id_in', as_index=True).sum(numeric_only=True) channels_df['routed_in_1day'] = forwards_in_df_1d_count.loc[chan_id].amt_out_msat channels_df['amt_routed_in_1day'] = int(forwards_in_df_1d_sum.loc[chan_id].amt_out_msat/1000) channels_df['average_in_1day'] = 0 if channels_df['routed_in_1day'][0] == 0 else int(channels_df['amt_routed_in_1day']/channels_df['routed_in_1day']) @@ -1155,7 +1155,7 @@ def channel(request): if forwards_out_df.shape[0]> 0: start_date = forwards_out_df['forward_date'].min() forwards_out_df_count = forwards_out_df.groupby('chan_id_out', as_index=True).count() - forwards_out_df_sum = forwards_out_df.groupby('chan_id_out', as_index=True).sum() + forwards_out_df_sum = forwards_out_df.groupby('chan_id_out', as_index=True).sum(numeric_only=True) channels_df['routed_out'] = forwards_out_df_count.loc[chan_id].amt_out_msat channels_df['amt_routed_out'] = int(forwards_out_df_sum.loc[chan_id].amt_out_msat/1000) channels_df['average_out'] = 0 if channels_df['routed_out'][0] == 0 else int(channels_df['amt_routed_out']/channels_df['routed_out']) @@ -1163,7 +1163,7 @@ def channel(request): forwards_out_df_30d = forwards_out_df.loc[forwards_out_df['forward_date'] >= filter_30day] if forwards_out_df_30d.shape[0] > 0: forwards_out_df_30d_count = forwards_out_df_30d.groupby('chan_id_out', as_index=True).count() - forwards_out_df_30d_sum = forwards_out_df_30d.groupby('chan_id_out', as_index=True).sum() + forwards_out_df_30d_sum = forwards_out_df_30d.groupby('chan_id_out', as_index=True).sum(numeric_only=True) channels_df['routed_out_30day'] = forwards_out_df_30d_count.loc[chan_id].amt_out_msat channels_df['amt_routed_out_30day'] = int(forwards_out_df_30d_sum.loc[chan_id].amt_out_msat/1000) channels_df['average_out_30day'] = 0 if channels_df['routed_out_30day'][0] == 0 else int(channels_df['amt_routed_out_30day']/channels_df['routed_out_30day']) @@ -1171,44 +1171,44 @@ def channel(request): forwards_out_df_7d = forwards_out_df_30d.loc[forwards_out_df_30d['forward_date'] >= filter_7day] if forwards_out_df_7d.shape[0] > 0: forwards_out_df_7d_count = forwards_out_df_7d.groupby('chan_id_out', as_index=True).count() - forwards_out_df_7d_sum = forwards_out_df_7d.groupby('chan_id_out', as_index=True).sum() + forwards_out_df_7d_sum = forwards_out_df_7d.groupby('chan_id_out', as_index=True).sum(numeric_only=True) channels_df['routed_out_7day'] = forwards_out_df_7d_count.loc[chan_id].amt_out_msat channels_df['amt_routed_out_7day'] = int(forwards_out_df_7d_sum.loc[chan_id].amt_out_msat/1000) channels_df['average_out_7day'] = 0 if channels_df['routed_out_7day'][0] == 0 else int(channels_df['amt_routed_out_7day']/channels_df['routed_out_7day']) channels_df['revenue_7day'] = int(forwards_out_df_7d_sum.loc[chan_id].fee) - forwards_out_df_7d_sum = forwards_out_df_7d[forwards_out_df_7d['amt_out_msat']>=1000000].groupby('chan_id_out', as_index=True).sum() + forwards_out_df_7d_sum = forwards_out_df_7d[forwards_out_df_7d['amt_out_msat']>=1000000].groupby('chan_id_out', as_index=True).sum(numeric_only=True) if forwards_out_df_7d_sum.shape[0] > 0: channels_df['amt_routed_out_7day_fees'] = int(forwards_out_df_7d_sum.loc[chan_id].amt_out_msat/1000) channels_df['revenue_7day_fees'] = int(forwards_out_df_7d_sum.loc[chan_id].fee) forwards_out_df_1d = forwards_out_df_7d.loc[forwards_out_df_7d['forward_date'] >= filter_1day] if forwards_out_df_1d.shape[0] > 0: forwards_out_df_1d_count = forwards_out_df_1d.groupby('chan_id_out', as_index=True).count() - forwards_out_df_1d_sum = forwards_out_df_1d.groupby('chan_id_out', as_index=True).sum() + forwards_out_df_1d_sum = forwards_out_df_1d.groupby('chan_id_out', as_index=True).sum(numeric_only=True) channels_df['routed_out_1day'] = forwards_out_df_1d_count.loc[chan_id].amt_out_msat channels_df['amt_routed_out_1day'] = int(forwards_out_df_1d_sum.loc[chan_id].amt_out_msat/1000) channels_df['average_out_1day'] = 0 if channels_df['routed_out_1day'][0] == 0 else int(channels_df['amt_routed_out_1day']/channels_df['routed_out_1day']) channels_df['revenue_1day'] = int(forwards_out_df_1d_sum.loc[chan_id].fee) if payments_df.shape[0] > 0: payments_df_count = payments_df.groupby('chan_out', as_index=True).count() - payments_df_sum = payments_df.groupby('chan_out', as_index=True).sum() + payments_df_sum = payments_df.groupby('chan_out', as_index=True).sum(numeric_only=True) channels_df['rebal_out'] = payments_df_count.loc[chan_id].value channels_df['amt_rebal_out'] = int(payments_df_sum.loc[chan_id].value) payments_df_30d = payments_df.loc[payments_df['creation_date'] >= filter_30day] if payments_df_30d.shape[0] > 0: payments_df_30d_count = payments_df_30d.groupby('chan_out', as_index=True).count() - payments_df_30d_sum = payments_df_30d.groupby('chan_out', as_index=True).sum() + payments_df_30d_sum = payments_df_30d.groupby('chan_out', as_index=True).sum(numeric_only=True) channels_df['rebal_out_30day'] = payments_df_30d_count.loc[chan_id].value channels_df['amt_rebal_out_30day'] = int(payments_df_30d_sum.loc[chan_id].value) payments_df_7d = payments_df_30d.loc[payments_df_30d['creation_date'] >= filter_7day] if payments_df_7d.shape[0] > 0: payments_df_7d_count = payments_df_7d.groupby('chan_out', as_index=True).count() - payments_df_7d_sum = payments_df_7d.groupby('chan_out', as_index=True).sum() + payments_df_7d_sum = payments_df_7d.groupby('chan_out', as_index=True).sum(numeric_only=True) channels_df['rebal_out_7day'] = payments_df_7d_count.loc[chan_id].value channels_df['amt_rebal_out_7day'] = int(payments_df_7d_sum.loc[chan_id].value) payments_df_1d = payments_df_7d.loc[payments_df_7d['creation_date'] >= filter_1day] if payments_df_1d.shape[0] > 0: payments_df_1d_count = payments_df_1d.groupby('chan_out', as_index=True).count() - payments_df_1d_sum = payments_df_1d.groupby('chan_out', as_index=True).sum() + payments_df_1d_sum = payments_df_1d.groupby('chan_out', as_index=True).sum(numeric_only=True) channels_df['rebal_out_1day'] = payments_df_1d_count.loc[chan_id].value channels_df['amt_rebal_out_1day'] = int(payments_df_1d_sum.loc[chan_id].value) if invoices_df.shape[0]> 0: @@ -1219,10 +1219,10 @@ def channel(request): invoices_df_30d_count = DataFrame() if invoices_df_30d.empty else invoices_df_30d.groupby('chan_in', as_index=True).count() invoices_df_7d_count = DataFrame() if invoices_df_7d.empty else invoices_df_7d.groupby('chan_in', as_index=True).count() invoices_df_1d_count = DataFrame() if invoices_df_1d.empty else invoices_df_1d.groupby('chan_in', as_index=True).count() - invoices_df_sum = DataFrame() if invoices_df.empty else invoices_df.groupby('chan_in', as_index=True).sum() - invoices_df_30d_sum = DataFrame() if invoices_df_30d.empty else invoices_df_30d.groupby('chan_in', as_index=True).sum() - invoices_df_7d_sum = DataFrame() if invoices_df_7d.empty else invoices_df_7d.groupby('chan_in', as_index=True).sum() - invoices_df_1d_sum = DataFrame() if invoices_df_1d.empty else invoices_df_1d.groupby('chan_in', as_index=True).sum() + invoices_df_sum = DataFrame() if invoices_df.empty else invoices_df.groupby('chan_in', as_index=True).sum(numeric_only=True) + invoices_df_30d_sum = DataFrame() if invoices_df_30d.empty else invoices_df_30d.groupby('chan_in', as_index=True).sum(numeric_only=True) + invoices_df_7d_sum = DataFrame() if invoices_df_7d.empty else invoices_df_7d.groupby('chan_in', as_index=True).sum(numeric_only=True) + invoices_df_1d_sum = DataFrame() if invoices_df_1d.empty else invoices_df_1d.groupby('chan_in', as_index=True).sum(numeric_only=True) channels_df['rebal_in'] = invoices_df_count.loc[chan_id].amt_paid if invoices_df_count.empty == False else 0 channels_df['rebal_in_30day'] = invoices_df_30d_count.loc[chan_id].amt_paid if invoices_df_30d_count.empty == False else 0 channels_df['rebal_in_7day'] = invoices_df_7d_count.loc[chan_id].amt_paid if invoices_df_7d_count.empty == False else 0