From 5bd061a5daac5676e0496d291326f793b02dac59 Mon Sep 17 00:00:00 2001 From: Neeraj Kashyap Date: Tue, 10 Aug 2021 06:25:23 -0700 Subject: [PATCH] Added stream_processors submodule Migrated streams route to use `ethereum_transaction` stream processor. --- backend/moonstream/routes/streams.py | 4 ++-- backend/moonstream/stream_processors/__init__.py | 0 .../ethereum_transaction.py} | 10 +++------- 3 files changed, 5 insertions(+), 9 deletions(-) create mode 100644 backend/moonstream/stream_processors/__init__.py rename backend/moonstream/{actions.py => stream_processors/ethereum_transaction.py} (97%) diff --git a/backend/moonstream/routes/streams.py b/backend/moonstream/routes/streams.py index 58e0b9a0..9f0436c7 100644 --- a/backend/moonstream/routes/streams.py +++ b/backend/moonstream/routes/streams.py @@ -12,7 +12,7 @@ from moonstreamdb import db from sqlalchemy.orm import Session -from .. import actions +from ..stream_processors import ethereum_transaction from .. import data from ..middleware import BroodAuthMiddleware from ..settings import ( @@ -96,7 +96,7 @@ async def search_transactions( if address_to_subscriptions: print("address_to_subscriptions") - response = await actions.get_transaction_in_blocks( + response = await ethereum_transaction.get_transaction_in_blocks( db_session=db_session, query=q, user_subscriptions_resources_by_address=address_to_subscriptions, diff --git a/backend/moonstream/stream_processors/__init__.py b/backend/moonstream/stream_processors/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/backend/moonstream/actions.py b/backend/moonstream/stream_processors/ethereum_transaction.py similarity index 97% rename from backend/moonstream/actions.py rename to backend/moonstream/stream_processors/ethereum_transaction.py index e62ff553..16f36d9f 100644 --- a/backend/moonstream/actions.py +++ b/backend/moonstream/stream_processors/ethereum_transaction.py @@ -1,21 +1,17 @@ -from datetime import datetime import logging +from typing import Dict, Any, List -from typing import Dict, Any, List, Optional, Union - -from sqlalchemy.engine.base import Transaction from moonstreamdb.models import ( EthereumBlock, EthereumTransaction, - EthereumPendingTransaction, ) from sqlalchemy import or_, and_, text from sqlalchemy.orm import Session -from . import data +from .. import data -from .settings import DEFAULT_STREAM_TIMEINTERVAL +from ..settings import DEFAULT_STREAM_TIMEINTERVAL logger = logging.getLogger(__name__)