From 52dbb8d17ba230883922640eaeee42f62d8a8211 Mon Sep 17 00:00:00 2001 From: jsl12 Date: Thu, 12 Aug 2021 10:51:19 -0500 Subject: [PATCH] small tweaks --- data.py | 12 ------------ msg.py | 8 ++++++-- robopage.py | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/data.py b/data.py index 9d746d7..b559006 100644 --- a/data.py +++ b/data.py @@ -122,18 +122,6 @@ class MsgData: return res - def biggest_daddy(self, days, top: int = None): - df = self.emoji_totals('daddy', days) - if top is not None: - df = df.iloc[:top] - width = max(list(map(lambda s: len(str(s)), df.index.values))) - res = f'Daddy totals, past {days} days\n' - res += '\n'.join( - f"`{name.ljust(width + 1)}with {row['total']:<2.0f} total`" - for name, row in df.iterrows() - ) - return res - async def biggest_single(self, client: discord.Client, emoji: str, days: int) -> str: data = self.emoji_totals(emoji_name=emoji, days=days) username = data.index[0] diff --git a/msg.py b/msg.py index abcb5a3..df2e986 100644 --- a/msg.py +++ b/msg.py @@ -5,6 +5,7 @@ from typing import Dict, Iterable import discord import pandas as pd +import pandas.errors from dotenv import load_dotenv LOGGER = logging.getLogger(__name__) @@ -89,8 +90,11 @@ def emoji_messages(msg_df, react_df, emoji_name: str, days: int = 10) -> pd.Data LOGGER.info( f'Found {reacted_msgs.shape[0]} messages for the leaderboard, {reactions["count"].sum():.0f} reactions total') - reacted_msgs['count'] = reacted_msgs.index.to_series().apply( - lambda idx: reactions.loc[pd.IndexSlice[idx, emoji_name], 'count']) + try: + reacted_msgs['count'] = reacted_msgs.index.to_series().apply( + lambda idx: reactions.loc[pd.IndexSlice[idx, emoji_name], 'count']) + except pandas.errors.InvalidIndexError as e: + LOGGER.error(f'{e}\n{reacted_msgs[reacted_msgs.index.duplicated()]}') reacted_msgs = reacted_msgs[ reacted_msgs['created'] >= (datetime.today() - timedelta(days=days)).astimezone()] diff --git a/robopage.py b/robopage.py index 89ccab2..7cafebe 100644 --- a/robopage.py +++ b/robopage.py @@ -41,7 +41,7 @@ class RoboPage(discord.Client): client=self, limit=3000, # limit=20, - days=14, + days=30, ) self.data.to_sql('messages.db') LOGGER.info(f'{self.data.msgs.shape[0]} messages total')