🗝
summary refs log tree commit diff
path: root/2_filter.py
diff options
context:
space:
mode:
Diffstat (limited to '2_filter.py')
-rw-r--r--2_filter.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/2_filter.py b/2_filter.py
index 8e77945..89311d2 100644
--- a/2_filter.py
+++ b/2_filter.py
@@ -1,19 +1,21 @@
+import time
 from dataclasses import dataclass
 from pathlib import Path
 from typing import Callable, List
 
 import psycopg
 
-from com import FilterableNote, Visibility, eval_config, parse_graph, progressbar
-
+from com import (FilterableNote, Visibility, eval_config, parse_graph,
+                 progressbar, FilterAction)
 
 config = eval_config()
 conn: psycopg.Connection = config["connect"]()
-criteria: Callable[[FilterableNote], bool] = config["criteria"]
+criteria: Callable[[FilterableNote], FilterAction] = config["criteria"]
 
 intermediate = parse_graph()
 
 def transform(entry: dict) -> FilterableNote:
+    time.sleep(0.0001)
     note = conn.execute(
         'select "createdAt", reactions, "renoteCount", visibility from note where id = %s',
         [entry["id"]],
@@ -57,10 +59,10 @@ for entry in intermediate.values():
     transformed = transform(entry)
     if transformed is None:
         continue # we'll get to it next cycle
-    if criteria(transformed):
-        targets.append(entry["id"])
+    action = criteria(transformed)
+    if action != FilterAction.Ignore:
+        targets.append(f"{entry['id']} {action.value}")
     pb.increment()
 pb.finish()
 
-
 Path("filtered.list").write_text("\n".join(targets))