From 0e069c26797fb5f4a47cb30fcaf75e73e69d9df5 Mon Sep 17 00:00:00 2001 From: hunteraraujo Date: Mon, 18 Sep 2023 17:15:44 -0700 Subject: [PATCH] Add generateCombinedReport Method and Rename Existing Method This commit introduces two major updates to the BenchmarkService class: 1. Renamed the `generateReport` method to `generateSingleReport` for better clarity and specificity. 2. Added a new method called `generateCombinedReport` that takes a list of test run IDs and generates a combined report by posting to the `/reports/query` endpoint. These changes aim to improve the modularity and readability of the code, while also extending its functionality to handle combined reports. --- frontend/lib/services/benchmark_service.dart | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/frontend/lib/services/benchmark_service.dart b/frontend/lib/services/benchmark_service.dart index e5358c27..5c19a973 100644 --- a/frontend/lib/services/benchmark_service.dart +++ b/frontend/lib/services/benchmark_service.dart @@ -8,28 +8,30 @@ class BenchmarkService { BenchmarkService(this.api); - /// Generates a report using POST REST API at the /reports URL. + /// Generates a single report using POST REST API at the /reports URL. /// - /// [reportRequestBody] is a Map representing the request body for generating a report. - Future> generateReport( + /// [reportRequestBody] is a Map representing the request body for generating a single report. + Future> generateSingleReport( ReportRequestBody reportRequestBody) async { try { return await api.post('reports', reportRequestBody.toJson(), apiType: ApiType.benchmark); } catch (e) { - throw Exception('Failed to generate report: $e'); + throw Exception('Failed to generate single report: $e'); } } - /// Polls for updates using the GET REST API at the /updates?last_update_time=TIMESTAMP URL. + /// Generates a combined report using POST REST API at the /reports/query URL. /// - /// [lastUpdateTime] is the UNIX UTC timestamp for last update time. - Future> pollUpdates(int lastUpdateTime) async { + /// [testRunIds] is a list of strings representing the test run IDs to be combined into a single report. + Future> generateCombinedReport( + List testRunIds) async { try { - return await api.get('updates?last_update_time=$lastUpdateTime', + final Map requestBody = {'test_run_ids': testRunIds}; + return await api.post('reports/query', requestBody, apiType: ApiType.benchmark); } catch (e) { - throw Exception('Failed to poll updates: $e'); + throw Exception('Failed to generate combined report: $e'); } } }