|
15 | 15 | use CDash\Database; |
16 | 16 | use CDash\Model\Build; |
17 | 17 | use CDash\Model\BuildGroupRule; |
18 | | -use CDash\Model\BuildRelationship; |
19 | 18 | use Illuminate\Http\JsonResponse; |
20 | 19 | use Illuminate\Http\Request; |
21 | 20 | use Illuminate\Support\Carbon; |
@@ -524,13 +523,6 @@ public function apiBuildSummary(): JsonResponse |
524 | 523 | } |
525 | 524 | $response['newissueurl'] = $new_issue_url; |
526 | 525 |
|
527 | | - // Check if this build is related to any others. |
528 | | - $build_relationship = new BuildRelationship(); |
529 | | - $relationships = $build_relationship->GetRelationships($this->build); |
530 | | - $response['relationships_to'] = $relationships['to']; |
531 | | - $response['relationships_from'] = $relationships['from']; |
532 | | - $response['hasrelationships'] = !empty($response['relationships_to']) || !empty($response['relationships_from']); |
533 | | - |
534 | 526 | $pageTimer->end($response); |
535 | 527 | return response()->json(cast_data_for_JSON($response)); |
536 | 528 | } |
@@ -710,89 +702,6 @@ public function apiBuildExpected(): JsonResponse |
710 | 702 | ]); |
711 | 703 | } |
712 | 704 |
|
713 | | - public function apiRelateBuilds(): JsonResponse |
714 | | - { |
715 | | - $this->setProjectByName(request()->string('project') ?? ''); |
716 | | - |
717 | | - if (!request()->has('buildid')) { |
718 | | - abort(400, '"buildid" parameter required.'); |
719 | | - } |
720 | | - if (!request()->has('relatedid')) { |
721 | | - abort(400, '"relatedid" parameter required.'); |
722 | | - } |
723 | | - |
724 | | - $buildid = (int) request()->input('buildid'); |
725 | | - $relatedid = (int) request()->input('relatedid'); |
726 | | - |
727 | | - $build = new Build(); |
728 | | - $build->Id = $buildid; |
729 | | - $relatedbuild = new Build(); |
730 | | - $relatedbuild->Id = $relatedid; |
731 | | - $buildRelationship = new BuildRelationship(); |
732 | | - $buildRelationship->Build = $build; |
733 | | - $buildRelationship->RelatedBuild = $relatedbuild; |
734 | | - $buildRelationship->Project = $this->project; |
735 | | - |
736 | | - switch (request()->method()) { |
737 | | - case 'GET': |
738 | | - return $this->apiRelateBuildsGet($buildRelationship); |
739 | | - case 'POST': |
740 | | - return $this->apiRelateBuildsPost($buildRelationship); |
741 | | - case 'DELETE': |
742 | | - return $this->apiRelateBuildsDelete($buildRelationship); |
743 | | - default: |
744 | | - abort(500, 'Unhandled method: ' . request()->method()); |
745 | | - } |
746 | | - } |
747 | | - |
748 | | - private function apiRelateBuildsGet(BuildRelationship $buildRelationship): JsonResponse |
749 | | - { |
750 | | - if ($buildRelationship->Exists()) { |
751 | | - $buildRelationship->Fill(); |
752 | | - return response()->json($buildRelationship->marshal()); |
753 | | - } |
754 | | - abort(404, "No relationship exists between Builds {$buildRelationship->Build->Id} and {$buildRelationship->RelatedBuild->Id}"); |
755 | | - } |
756 | | - |
757 | | - private function apiRelateBuildsPost(BuildRelationship $buildRelationship): JsonResponse |
758 | | - { |
759 | | - // Create or update the relationship between these two builds. |
760 | | - if (!request()->has('relationship')) { |
761 | | - abort(400, '"relationship" parameter required.'); |
762 | | - } |
763 | | - $relationship = request()->input('relationship'); |
764 | | - $buildRelationship->Relationship = $relationship; |
765 | | - $exit_status = 200; |
766 | | - if (!$buildRelationship->Exists()) { |
767 | | - $exit_status = 201; |
768 | | - } |
769 | | - if (!$buildRelationship->Save($error_msg)) { |
770 | | - if ($error_msg) { |
771 | | - abort(400, $error_msg); |
772 | | - } else { |
773 | | - abort(500, 'Error saving relationship'); |
774 | | - } |
775 | | - } |
776 | | - return response()->json($buildRelationship->marshal(), $exit_status); |
777 | | - } |
778 | | - |
779 | | - private function apiRelateBuildsDelete(BuildRelationship $buildRelationship): JsonResponse |
780 | | - { |
781 | | - if (can_administrate_project($this->project->Id)) { |
782 | | - if ($buildRelationship->Exists()) { |
783 | | - if (!$buildRelationship->Delete($error_msg)) { |
784 | | - if ($error_msg) { |
785 | | - abort(400, $error_msg); |
786 | | - } else { |
787 | | - abort(500, 'Error deleting relationship'); |
788 | | - } |
789 | | - } |
790 | | - } |
791 | | - abort(204); |
792 | | - } |
793 | | - return response()->json(); |
794 | | - } |
795 | | - |
796 | 705 | public function restApi(): JsonResponse |
797 | 706 | { |
798 | 707 | $this->setBuildById((int) request()->input('buildid', -1)); |
|
0 commit comments