Skip to content

Commit 839378e

Browse files
Remove unused /api/v1/relateBuilds.php endpoint (Kitware#3657)
This feature was originally build to support a one-off use case and is no longer relevant. In the future, a completely redesigned version of this may make sense if there's sufficient interest. It should be better integrated with the UI if it's introduced though.
1 parent 4a8cfae commit 839378e

10 files changed

Lines changed: 22 additions & 837 deletions

File tree

app/Http/Controllers/BuildController.php

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use CDash\Database;
1616
use CDash\Model\Build;
1717
use CDash\Model\BuildGroupRule;
18-
use CDash\Model\BuildRelationship;
1918
use Illuminate\Http\JsonResponse;
2019
use Illuminate\Http\Request;
2120
use Illuminate\Support\Carbon;
@@ -524,13 +523,6 @@ public function apiBuildSummary(): JsonResponse
524523
}
525524
$response['newissueurl'] = $new_issue_url;
526525

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-
534526
$pageTimer->end($response);
535527
return response()->json(cast_data_for_JSON($response));
536528
}
@@ -710,89 +702,6 @@ public function apiBuildExpected(): JsonResponse
710702
]);
711703
}
712704

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-
796705
public function restApi(): JsonResponse
797706
{
798707
$this->setBuildById((int) request()->input('buildid', -1));

app/cdash/app/Model/BuildRelationship.php

Lines changed: 0 additions & 226 deletions
This file was deleted.

app/cdash/tests/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,8 @@ add_legacy_unit_test(/CDash/Model/Repository)
141141
add_laravel_test(/Feature/CDashTest)
142142
set_tests_properties(/Feature/CDashTest PROPERTIES DEPENDS install_1)
143143

144-
add_legacy_unit_test(/CDash/Model/BuildRelationship)
145-
set_tests_properties(/CDash/Model/BuildRelationship PROPERTIES DEPENDS /Feature/CDashTest)
146-
147144
add_legacy_unit_test(/CDash/MultipleSubprojectsEmail)
148-
set_tests_properties(/CDash/MultipleSubprojectsEmail PROPERTIES DEPENDS /CDash/Model/BuildRelationship)
145+
set_tests_properties(/CDash/MultipleSubprojectsEmail PROPERTIES DEPENDS /Feature/CDashTest)
149146

150147
add_legacy_unit_test(/CDash/NightlyTime)
151148
set_tests_properties(/CDash/NightlyTime PROPERTIES DEPENDS /CDash/MultipleSubprojectsEmail)

0 commit comments

Comments
 (0)