diff --git a/bot/extensions/fun/freudr.py b/bot/extensions/fun/freudr.py index 6d1fb11..3f6a48d 100644 --- a/bot/extensions/fun/freudr.py +++ b/bot/extensions/fun/freudr.py @@ -1,4 +1,3 @@ -import asyncio import time from discord import Member, app_commands, Interaction, Embed @@ -6,19 +5,9 @@ from bot.decorators import check_user_is_verified from bot.extensions import ErrorHandledCog from models.profile import Profile -from models.profile_statistics import ProfileStatistics class Freudr(ErrorHandledCog): - @staticmethod - async def ensure_has_statistics(id1: int, id2: int, guild_id: int): - await asyncio.gather( - *[ - ProfileStatistics.get(id1, guild_id), - ProfileStatistics.get(id2, guild_id), - ] - ) - @staticmethod def hash_match(user_id, crush_id) -> int: if user_id <= crush_id: @@ -68,8 +57,6 @@ async def like(self, ia: Interaction, crush: Member): ephemeral=True, ) - await self.ensure_has_statistics(ia.user.id, crush.id, ia.guild_id) - profile = await Profile.find_by_discord_id(ia.user.id) if crush.id in profile.crushes: @@ -129,8 +116,6 @@ async def unlike(self, ia: Interaction, crush: Member): "https://www.wikihow.com/Love-Yourself", ephemeral=True ) - await self.ensure_has_statistics(ia.user.id, crush.id, ia.guild_id) - profile = await Profile.find_by_discord_id(ia.user.id) if crush.id not in profile.crushes: @@ -155,8 +140,6 @@ async def unlike(self, ia: Interaction, crush: Member): async def show_list(self, ia: Interaction): profile = await Profile.find_by_discord_id(ia.user.id) - await self.ensure_has_statistics(ia.user.id, ia.user.id, ia.guild_id) - if not profile.crushes: return await ia.response.send_message( "You don't have any crushes, use '/freudr like ' to get started", diff --git a/bot/extensions/fun/stats/overview.py b/bot/extensions/fun/stats/overview.py index 8affa15..212901c 100644 --- a/bot/extensions/fun/stats/overview.py +++ b/bot/extensions/fun/stats/overview.py @@ -23,10 +23,6 @@ def __init__(self): label="Confession Exposures", value="exposed", ), - SelectOption( - label="Freudr Likes", - value="crush", - ), ] super().__init__(options=options) @@ -47,9 +43,6 @@ async def callback(self, ia: Interaction): elif value == "exposed": self.set_default_option(1) leaderboard = await self.make_exposed_leaderboard(ia) - elif value == "crush": - self.set_default_option(2) - leaderboard = await self.make_crush_leaderboard(ia) else: raise ValueError() @@ -85,16 +78,6 @@ async def make_exposed_leaderboard(ia: Interaction) -> Embed: return Embed(title="Most exposed members", description="\n".join(top_10)) - @staticmethod - async def make_crush_leaderboard(ia: Interaction) -> Embed: - top_10 = await Profile.get_most_liked_top_10(ia.guild_id) - - top_10 = [f"#{i + 1} - <@{p[0]}> ({p[1]})" for i, p in enumerate(top_10)] - - return Embed( - title="Members with the most likes on Freudr", description="\n".join(top_10) - ) - class Leaderboard(View): def __init__(self, owner: Member): @@ -121,7 +104,6 @@ async def show_me(self, ia: Interaction): stats = await ProfileStatistics.get(ia.user.id, ia.guild_id) rank = await user.get_freudpoint_rank(ia.guild_id) - likes = await user.get_freudr_likes() profile_embed = ( Embed(title=f"{ia.user.display_name}s Profile", colour=ia.user.colour) @@ -141,11 +123,6 @@ async def show_me(self, ia: Interaction): value=stats.confession_exposed_count, inline=False, ) - .add_field( - name="Likes on Freudr", - value=likes, - inline=False, - ) ) return await ia.response.send_message(embed=profile_embed) diff --git a/models/profile.py b/models/profile.py index 7f511b9..1533876 100644 --- a/models/profile.py +++ b/models/profile.py @@ -110,38 +110,6 @@ async def find_verified_in_guild(cls, guild: Guild) -> list["Profile"]: ) return list(profiles) - @classmethod - async def get_most_liked_top_10(cls, guild_id: int) -> list[tuple[int, int]]: - """Get a top 10 of the most liked profiles""" - - async with session_factory() as session: - result: Result = await session.execute( - text( - """ - select - discord_id, - ( - select count(*) - from profile p2 - where p1.discord_id = ANY(p2.crushes) - ) as likes - from profile p1 - where exists( - select * - from profile_statistics ps - where - ps.profile_discord_id=p1.discord_id - and ps.config_guild_id=:guild_id - ) - order by likes desc - limit 10; - """ - ), - {"guild_id": guild_id}, - ) - - return result.all() - async def get_freudpoint_rank(self, guild_id: int) -> int: """Get a profiles FreudPoint score rank in a given guild""" @@ -157,23 +125,6 @@ async def get_freudpoint_rank(self, guild_id: int) -> int: return profiles.index(self) - async def get_freudr_likes(self) -> int: - """Get the total number of likes this profile has on Freudr""" - - async with session_factory() as session: - result: Result = await session.execute( - text( - """ - select count(*) - from profile p - where :discord_id = ANY(p.crushes); - """ - ), - {"discord_id": self.discord_id}, - ) - - return result.first()[0] - def is_verified(self) -> bool: """Check if a profile is verified"""