@@ -648,18 +648,18 @@ class Meta:
648648 "log" ,
649649 ]
650650
651- def get_status (self , obj ):
652- return obj .status
651+ def get_status (self , run ):
652+ return run .status
653653
654- def get_execution_time (self , obj ):
655- return round (obj .execution_time , 2 )
654+ def get_execution_time (self , run ):
655+ return round (run .execution_time , 2 )
656656
657657
658658class PipelineScheduleAPISerializer (serializers .HyperlinkedModelSerializer ):
659659 url = serializers .HyperlinkedIdentityField (
660660 view_name = "schedule-detail" , lookup_field = "pipeline_id"
661661 )
662- pipelineruns = PipelineRunAPISerializer ( many = True , read_only = True )
662+ latest_run = serializers . SerializerMethodField ( )
663663 next_run_date = serializers .SerializerMethodField ()
664664
665665 class Meta :
@@ -672,11 +672,16 @@ class Meta:
672672 "created_date" ,
673673 "schedule_work_id" ,
674674 "next_run_date" ,
675- "pipelineruns " ,
675+ "latest_run " ,
676676 ]
677677
678- def get_next_run_date (self , obj ):
679- return obj .next_run_date
678+ def get_next_run_date (self , schedule ):
679+ return schedule .next_run_date
680+
681+ def get_latest_run (self , schedule ):
682+ if latest := schedule .pipelineruns .first ():
683+ return PipelineRunAPISerializer (latest ).data
684+ return None
680685
681686
682687class PipelineScheduleCreateSerializer (serializers .ModelSerializer ):
0 commit comments