Spaces:
Sleeping
Sleeping
REFINE: replace ValueError with WorkspaceNotFoundError in workspace and Shopify credentials retrieval
Browse files
services/query_service.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
import logging
|
| 2 |
import threading
|
| 3 |
-
from core.config import query_executor
|
| 4 |
from core.cache import credentials_cache, instant_reply_cache, rate_limiter
|
|
|
|
| 5 |
from repositories.comment import insert_comment
|
| 6 |
from repositories.social_account import (
|
| 7 |
get_shopify_credentials as get_shopify_credentials_for_workspace,
|
|
@@ -23,9 +24,9 @@ class RateLimitExceeded(Exception):
|
|
| 23 |
def get_workspace_by_channel(channel: str, channel_identifier: str) -> tuple:
|
| 24 |
try:
|
| 25 |
workspace, channel_row = get_workspace_for_channel(channel, channel_identifier)
|
| 26 |
-
except
|
| 27 |
logger.warning(f"No workspace found for {channel}: {channel_identifier}")
|
| 28 |
-
raise
|
| 29 |
|
| 30 |
logger.debug(f"Resolved channel {channel_identifier} to workspace {workspace['id']}")
|
| 31 |
return workspace, channel_row
|
|
@@ -40,9 +41,9 @@ def get_shopify_credentials(workspace_id: str) -> dict:
|
|
| 40 |
|
| 41 |
try:
|
| 42 |
credentials = get_shopify_credentials_for_workspace(workspace_id)
|
| 43 |
-
except
|
| 44 |
logger.warning(f"No Shopify channel found for workspace {workspace_id}")
|
| 45 |
-
raise
|
| 46 |
|
| 47 |
credentials_cache.set(cache_key, credentials)
|
| 48 |
return credentials
|
|
|
|
| 1 |
import logging
|
| 2 |
import threading
|
| 3 |
+
from core.config import query_executor
|
| 4 |
from core.cache import credentials_cache, instant_reply_cache, rate_limiter
|
| 5 |
+
from core.exceptions import WorkspaceNotFoundError
|
| 6 |
from repositories.comment import insert_comment
|
| 7 |
from repositories.social_account import (
|
| 8 |
get_shopify_credentials as get_shopify_credentials_for_workspace,
|
|
|
|
| 24 |
def get_workspace_by_channel(channel: str, channel_identifier: str) -> tuple:
|
| 25 |
try:
|
| 26 |
workspace, channel_row = get_workspace_for_channel(channel, channel_identifier)
|
| 27 |
+
except WorkspaceNotFoundError:
|
| 28 |
logger.warning(f"No workspace found for {channel}: {channel_identifier}")
|
| 29 |
+
raise
|
| 30 |
|
| 31 |
logger.debug(f"Resolved channel {channel_identifier} to workspace {workspace['id']}")
|
| 32 |
return workspace, channel_row
|
|
|
|
| 41 |
|
| 42 |
try:
|
| 43 |
credentials = get_shopify_credentials_for_workspace(workspace_id)
|
| 44 |
+
except WorkspaceNotFoundError:
|
| 45 |
logger.warning(f"No Shopify channel found for workspace {workspace_id}")
|
| 46 |
+
raise
|
| 47 |
|
| 48 |
credentials_cache.set(cache_key, credentials)
|
| 49 |
return credentials
|