mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 06:24:20 +01:00
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.
This commit is contained in:
@@ -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<Map<String, dynamic>> generateReport(
|
||||
/// [reportRequestBody] is a Map representing the request body for generating a single report.
|
||||
Future<Map<String, dynamic>> 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<Map<String, dynamic>> pollUpdates(int lastUpdateTime) async {
|
||||
/// [testRunIds] is a list of strings representing the test run IDs to be combined into a single report.
|
||||
Future<Map<String, dynamic>> generateCombinedReport(
|
||||
List<String> testRunIds) async {
|
||||
try {
|
||||
return await api.get('updates?last_update_time=$lastUpdateTime',
|
||||
final Map<String, dynamic> 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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user