From 17d43d2f3e90cf613143b1723284b1af8c09196b Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 19 Sep 2023 17:25:39 +0300 Subject: [PATCH] Add changes. --- .../mooncrawl/mooncrawl/moonworm_crawler/cli.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crawlers/mooncrawl/mooncrawl/moonworm_crawler/cli.py b/crawlers/mooncrawl/mooncrawl/moonworm_crawler/cli.py index a265603d..4e244f49 100644 --- a/crawlers/mooncrawl/mooncrawl/moonworm_crawler/cli.py +++ b/crawlers/mooncrawl/mooncrawl/moonworm_crawler/cli.py @@ -7,6 +7,7 @@ from moonstreamdb.blockchain import AvailableBlockchainType from web3 import Web3 from web3.middleware import geth_poa_middleware +from .db import deduplicate_records from ..db import yield_db_session_ctx from ..settings import ( MOONSTREAM_MOONWORM_TASKS_JOURNAL, @@ -341,6 +342,21 @@ def handle_historical_crawl(args: argparse.Namespace) -> None: ) +def handle_deduplicate(args: argparse.Namespace) -> None: + """ + Deduplicate database records + """ + + with yield_db_session_ctx() as db_session: + deduplicate_records( + db_session, + args.blockchain_type, + args.table, + args.label, + args.type, + ) + + def main() -> None: parser = argparse.ArgumentParser() parser.set_defaults(func=lambda _: parser.print_help())