diff options
author | mia <mia@mia.jetzt> | 2024-10-04 15:43:40 -0700 |
---|---|---|
committer | mia <mia@mia.jetzt> | 2024-10-04 15:43:40 -0700 |
commit | 7e060e5cf2656a0a53d41ea0ff42b753316cd441 (patch) | |
tree | 2629f3d1e12d21c406974000dd195518aa5b6041 /2_filter.py | |
parent | bb8a48fd4d85ba4f8224c68aaaf9069d5d79dae2 (diff) | |
download | scrubber-7e060e5cf2656a0a53d41ea0ff42b753316cd441.tar.gz scrubber-7e060e5cf2656a0a53d41ea0ff42b753316cd441.zip |
she's goin
Diffstat (limited to '2_filter.py')
-rw-r--r-- | 2_filter.py | 14 |
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)) |