moved top_cancellations to worst_offesnes in MsgData

This commit is contained in:
2021-08-10 22:30:35 -05:00
parent 6a359d85ff
commit 5745c55f9d
2 changed files with 17 additions and 17 deletions

15
msg.py
View File

@@ -114,6 +114,19 @@ class MsgData:
)
return res
def worst_offsenses(self, user: str, days: int):
cdf = self.cancellations(days=days)
cdf = cdf[cdf['display_name'].str.contains(user, case=False)]
if cdf.shape[0] > 0:
res = f'{user}\'s top 5 cancellations in the last {days} days:\n'
res += f'\n'.join(
f'`{row["count"]:<2.0f}cancellations`\n{row["link"]}' for idx, row in cdf.iloc[:5].iterrows())
else:
res = f'No cancellations for {user} in the past {days} days'
return res
async def message_df(client: discord.Client, **kwargs):
return pd.DataFrame(
@@ -203,7 +216,7 @@ def cancelled_totals(cdf: pd.DataFrame) -> pd.DataFrame:
return pd.DataFrame({
'total': totals,
'max channel': max_channels,
'worst': cdf.groupby('display_name').max()['link']
# 'worst': cdf.groupby('display_name').max()['link']
}).sort_values('total', ascending=False)