Skip to content

Commit

Permalink
Only categories
Browse files Browse the repository at this point in the history
  • Loading branch information
squeaky-pl committed Nov 14, 2024
1 parent 3fc5c0a commit d8c2160
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bin/recategorize-messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ def yield_account_id_and_message_ids(
@click.option("--only-account-id", type=int, default=None)
@click.option("--only-inbox", is_flag=True, default=False)
@click.option("--only-types", default=",".join(ALL_ACCOUNT_TYPES))
@click.option("--only-categories", default=None)
@click.option("--dry-run/--no-dry-run", default=True)
def main(
only_account_id: int | None,
only_inbox: bool,
only_types: str,
only_categories: str | None,
date_start: datetime.date | None,
date_end: datetime.date | None,
dry_run: bool,
Expand Down Expand Up @@ -137,6 +139,12 @@ def session_factory():
category.name for category in message.categories if category.name
)
if old_categories != new_categories:
if only_categories and not new_categories & only_categories.split(
","
):
session.rollback()
continue

changed_counter += 1
print(
f"\t{message.id=}, {message.message_id_header=}, {old_categories=} to {new_categories=}"
Expand Down

0 comments on commit d8c2160

Please sign in to comment.