From 7e060e5cf2656a0a53d41ea0ff42b753316cd441 Mon Sep 17 00:00:00 2001 From: mia Date: Fri, 4 Oct 2024 15:43:40 -0700 Subject: she's goin --- 2_filter.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to '2_filter.py') 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)) -- cgit 1.4.1