diff --git a/backend/pipeline/models.py b/backend/pipeline/models.py index bf0dc5494..d4130ca3d 100644 --- a/backend/pipeline/models.py +++ b/backend/pipeline/models.py @@ -4,6 +4,7 @@ from django.conf import settings from django.db import connection, models from utils.models.base_model import BaseModel +from workflow_manager.endpoint.models import WorkflowEndpoint from workflow_manager.workflow.models.workflow import Workflow from backend.constants import FieldLengthConstants as FieldLength @@ -93,7 +94,17 @@ def api_key_data(self): def api_endpoint(self): org_schema = connection.tenant.schema_name deployment_endpoint = settings.API_DEPLOYMENT_PATH_PREFIX + "/pipeline/api" + + # Check if the WorkflowEndpoint has a connection_type of MANUALREVIEW + workflow_endpoint = WorkflowEndpoint.objects.filter( + workflow=self.workflow, + connection_type=WorkflowEndpoint.ConnectionType.MANUALREVIEW, + ).first() api_endpoint = f"{deployment_endpoint}/{org_schema}/{self.id}/" + if workflow_endpoint: + deployment_endpoint = f"mr/api/{org_schema}/approved/result" + api_endpoint = f"{deployment_endpoint}/{self.workflow_id}/" + return api_endpoint def __str__(self) -> str: diff --git a/backend/pipeline/views.py b/backend/pipeline/views.py index 09e9bd204..8abd6b333 100644 --- a/backend/pipeline/views.py +++ b/backend/pipeline/views.py @@ -1,6 +1,6 @@ import json import logging -from typing import Optional +from typing import Any, Optional from account.custom_exceptions import DuplicateData from api.exceptions import NoActiveAPIKeyError @@ -36,6 +36,8 @@ class PipelineViewSet(viewsets.ModelViewSet): def get_queryset(self) -> Optional[QuerySet]: type = self.request.query_params.get(PipelineConstants.TYPE) if type is not None: + if type == "MRQ": + type = "ETL" queryset = Pipeline.objects.filter( created_by=self.request.user, pipeline_type=type ) @@ -50,6 +52,30 @@ def get_serializer_class(self) -> serializers.Serializer: else: return PipelineSerializer + def list(self, request: Request, *args: Any, **kwargs: Any) -> Response: + queryset = self.get_queryset() + serializer = self.get_serializer(queryset, many=True) + data = serializer.data + + # Check if the request is for 'MRQ' + etl_type = request.query_params.get(PipelineConstants.TYPE) + if etl_type == "MRQ": + # Filter the data based on 'destination_name' + filtered_data = [ + item for item in data if item["destination_name"] == "Manual Review" + ] + return Response(filtered_data) + + if etl_type == "ETL": + # Filter the data to exclude those with + # 'destination_name' == "Manual Review" + filtered_data = [ + item for item in data if item["destination_name"] != "Manual Review" + ] + return Response(filtered_data) + # If 'type' is not 'MRQ', return the default list + return super().list(request, *args, **kwargs) + # TODO: Refactor to perform an action with explicit arguments # For eg, passing pipeline ID and with_log=False -> executes pipeline # For FE however we call the same API twice diff --git a/frontend/src/components/agency/actions/Actions.jsx b/frontend/src/components/agency/actions/Actions.jsx index bfde51b8d..fc12ca31a 100644 --- a/frontend/src/components/agency/actions/Actions.jsx +++ b/frontend/src/components/agency/actions/Actions.jsx @@ -63,7 +63,7 @@ function Actions({ statusBarMsg, initializeWfComp, stepLoader }) { const axiosPrivate = useAxiosPrivate(); const { posthogWfDeploymentEventText, setPostHogCustomEvent } = usePostHogEvents(); - + const isManualReview = destination?.connection_type === "MANUALREVIEW"; useEffect(() => { // Enable Deploy as API only when // Source & Destination connection_type are selected as API @@ -84,7 +84,7 @@ function Actions({ statusBarMsg, initializeWfComp, stepLoader }) { source?.connector_instance && ((destination?.connection_type === "DATABASE" && destination.connector_instance) || - destination.connection_type === "MANUALREVIEW") + isManualReview) ); }, [source, destination]); useEffect(() => { @@ -307,10 +307,7 @@ function Actions({ statusBarMsg, initializeWfComp, stepLoader }) { ) { return false; } - if ( - source?.connection_type === "FILESYSTEM" && - destination?.connection_type === "MANUALREVIEW" - ) { + if (source?.connection_type === "FILESYSTEM" && isManualReview) { return false; } return !source?.connector_instance || !destination?.connector_instance; @@ -497,7 +494,9 @@ function Actions({ statusBarMsg, initializeWfComp, stepLoader }) { - +