From 9d4d4fd4ebf7ba82a67ce8b4dd27ded3f5f4de4c Mon Sep 17 00:00:00 2001 From: 0x16c3 <0x16c3@gmail.com> Date: Fri, 22 Apr 2022 19:30:01 +0300 Subject: [PATCH] Add started filter --- cogs/api/database.py | 38 ++++++++++++++++++++++++++++++++++---- cogs/api/types.py | 4 +++- cogs/controller.py | 20 +++++++++++++++----- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/cogs/api/database.py b/cogs/api/database.py index 3e1ed1c..92dae52 100644 --- a/cogs/api/database.py +++ b/cogs/api/database.py @@ -49,7 +49,14 @@ async def channel_insert(self, items: List[Any]) -> None: loop = asyncio.get_event_loop() for item in items: - for status in ["progress", "completion", "planning", "dropped", "paused"]: + for status in [ + "progress", + "started", + "completion", + "planning", + "dropped", + "paused", + ]: if not f"list_block_{status}" in item: item[f"list_block_{status}"] = False @@ -58,7 +65,14 @@ async def channel_insert(self, items: List[Any]) -> None: async def channel_update(self, id, item: Any) -> None: loop = asyncio.get_event_loop() - for status in ["progress", "completion", "planning", "dropped", "paused"]: + for status in [ + "progress", + "started", + "completion", + "planning", + "dropped", + "paused", + ]: if not f"list_block_{status}" in item: item[f"list_block_{status}"] = False @@ -78,7 +92,14 @@ async def channel_repair(self, id) -> None: loop = asyncio.get_event_loop() channel = self.channels.get(where("channel") == int(id)) - for status in ["progress", "completion", "planning", "dropped", "paused"]: + for status in [ + "progress", + "started", + "completion", + "planning", + "dropped", + "paused", + ]: if not f"list_block_{status}" in channel: channel[f"list_block_{status}"] = False @@ -97,7 +118,14 @@ async def channel_repair(self, id) -> None: async def _channel_remove(self, item: Any) -> bool: loop = asyncio.get_event_loop() - for status in ["progress", "completion", "planning", "dropped", "paused"]: + for status in [ + "progress", + "started", + "completion", + "planning", + "dropped", + "paused", + ]: if not f"list_block_{status}" in item: item[f"list_block_{status}"] = False @@ -108,6 +136,8 @@ async def _channel_remove(self, item: Any) -> bool: ( (where("channel") == item["channel"]) & (where("list_block_progress") == item["list_block_progress"]) + & (where("list_block_started") == item["list_block_started"]) + & (where("list_block_completion") == item["list_block_completion"]) & (where("list_block_planning") == item["list_block_planning"]) & (where("list_block_dropped") == item["list_block_dropped"]) & (where("list_block_paused") == item["list_block_paused"]) diff --git a/cogs/api/types.py b/cogs/api/types.py index 4e5c67c..4937f7e 100644 --- a/cogs/api/types.py +++ b/cogs/api/types.py @@ -395,7 +395,9 @@ async def send_embed( "CURRENT", "REPEATING", ] or item.status in ["REWATCHED", "REREAD"]: - if ch["list_block_progress"]: + if listitem.progress <= 1 and ch["list_block_started"]: + return None + elif ch["list_block_progress"]: return None elif listitem.status in ["COMPLETED"]: if ch["list_block_completion"]: diff --git a/cogs/controller.py b/cogs/controller.py index a1a22da..8288b7b 100644 --- a/cogs/controller.py +++ b/cogs/controller.py @@ -1031,6 +1031,7 @@ async def _filter(self, ctx: SlashContext): current = { "channel": ctx.channel.id, "list_block_progress": False, + "list_block_started": False, "list_block_completion": False, "list_block_planning": False, "list_block_dropped": False, @@ -1045,9 +1046,16 @@ async def _filter(self, ctx: SlashContext): value=i, default=not current[f"list_block_{i}"], ) - for i in ["progress", "completion", "planning", "dropped", "paused"] + for i in [ + "progress", + "started", + "completion", + "planning", + "dropped", + "paused", + ] ], - max_values=5, + max_values=6, placeholder="Filter enabled list activities for this channel.", ) actionrow = create_actionrow(select) @@ -1071,7 +1079,7 @@ def check_author(cctx: ComponentContext): selected: List[str] = [i for i in button_ctx.selected_options] await button_ctx.defer(edit_origin=True) - for i in ["progress", "planning", "dropped", "paused"]: + for i in ["progress", "started", "planning", "dropped", "paused"]: if i in selected and current[f"list_block_{i}"]: current[f"list_block_{i}"] = False elif i not in selected and not current[f"list_block_{i}"]: @@ -1098,13 +1106,14 @@ def check_author(cctx: ComponentContext): ) for i in [ "progress", + "started", "completion", "planning", "dropped", "paused", ] ], - max_values=5, + max_values=6, placeholder="Filter enabled list activities for this channel.", ) actionrow = create_actionrow(select) @@ -1123,13 +1132,14 @@ def check_author(cctx: ComponentContext): ) for i in [ "progress", + "started", "completion", "planning", "dropped", "paused", ] ], - max_values=5, + max_values=6, placeholder="Filter enabled list activities for this channel.", disabled=True, )