Skip to content

Commit

Permalink
wfm update for ui fix
Browse files Browse the repository at this point in the history
  • Loading branch information
raylrui committed Oct 17, 2024
1 parent cf80304 commit a291e21
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class StateBaseSerializer(SerializersBase):
class StateMinSerializer(StateBaseSerializer):
class Meta:
model = State
fields = ["orcabus_id", "status"]
fields = ["orcabus_id", "status", "timestamp"]


class StateSerializer(StateBaseSerializer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class WorkflowBaseSerializer(SerializersBase):
class WorkflowMinSerializer(WorkflowBaseSerializer):
class Meta:
model = Workflow
fields = ["orcabus_id", "workflow_name"]
fields = ["orcabus_id", "workflow_name", "workflow_version"]


class WorkflowSerializer(WorkflowBaseSerializer):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from rest_framework import serializers

from workflow_manager.serializers.base import SerializersBase
from workflow_manager.models import WorkflowRun, Workflow, AnalysisRun
from workflow_manager.models import WorkflowRun, AnalysisRun
from workflow_manager.serializers.state import StateSerializer, StateMinSerializer


class WorkflowRunBaseSerializer(SerializersBase):
prefix = WorkflowRun.orcabus_id_prefix

Expand All @@ -18,13 +17,16 @@ def get_current_state(self, obj) -> dict:


class WorkflowRunSerializer(WorkflowRunBaseSerializer):
from .workflow import WorkflowMinSerializer

workflow = WorkflowMinSerializer(read_only=True)
class Meta:
model = WorkflowRun
exclude = ["libraries"]

def to_representation(self, instance):
representation = super().to_representation(instance)
representation['workflow'] = Workflow.orcabus_id_prefix + representation['workflow']
# representation['workflow'] = Workflow.orcabus_id_prefix + representation['workflow']
if representation['analysis_run']:
representation['analysis_run'] = AnalysisRun.orcabus_id_prefix + representation['analysis_run']
return representation
Expand Down Expand Up @@ -55,6 +57,7 @@ class WorkflowRunCountByStatusSerializer(serializers.Serializer):
succeeded = serializers.IntegerField()
aborted = serializers.IntegerField()
failed = serializers.IntegerField()
resolved = serializers.IntegerField()
ongoing = serializers.IntegerField()

def update(self, instance, validated_data):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# may no longer need this as it's currently included in the detail response for an individual WorkflowRun record
router.register(
"workflowrun/(?P<workflowrun_id>[^/.]+)/state",
"workflowrun/(?P<wfr_orcabus_id>[^/.]+)/state",
StateViewSet,
basename="workflowrun-state",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ def list(self, request, *args, **kwargs):

def get_queryset(self):
query_params = self.get_query_params()
qs = State.objects.filter(workflow_run=self.kwargs["workflowrun_id"])
qs = State.objects.filter(workflow_run=self.kwargs["wfr_orcabus_id"])
return State.objects.get_by_keyword(qs, **query_params)
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ def count_by_status(self, request):
states__status="FAILED"
).count()

resolved_count = annotate_queryset.filter(
states__timestamp=F('latest_state_time'),
states__status="RESOLVED"
).count()

ongoing_count = base_queryset.filter(
~Q(states__status="FAILED") &
~Q(states__status="ABORTED") &
Expand All @@ -173,5 +178,6 @@ def count_by_status(self, request):
'succeeded': succeeded_count,
'aborted': aborted_count,
'failed': failed_count,
'resolved': resolved_count,
'ongoing': ongoing_count
}, status=200)

0 comments on commit a291e21

Please sign in to comment.