Add RepositoryInfo Class for Benchmark Repository and Team Details

This commit introduces the RepositoryInfo class, designed to encapsulate details about the repository and team associated with a benchmark run.

The class includes the following fields:
- repoUrl: The URL of the repository where the benchmark code resides.
- teamName: The name of the team responsible for the benchmark.
- benchmarkGitCommitSha: The Git commit SHA for the benchmark code.
- agentGitCommitSha: The Git commit SHA for the agent code.

The class supports JSON serialization and deserialization, making it easy to use with Flutter's JSON handling mechanisms.
This commit is contained in:
hunteraraujo
2023-09-20 13:17:46 -07:00
parent fc193568b9
commit 311f69b7cf

View File

@@ -0,0 +1,51 @@
/// `RepositoryInfo` encapsulates details about the repository and team associated with a benchmark run.
///
/// This class contains essential information like the repository URL, team name, and the Git commit SHA for both the benchmark and the agent.
class RepositoryInfo {
/// The URL of the repository where the benchmark code resides.
final String repoUrl;
/// The name of the team responsible for the benchmark.
final String teamName;
/// The Git commit SHA for the benchmark. This helps in tracing the exact version of the benchmark code.
final String benchmarkGitCommitSha;
/// The Git commit SHA for the agent. This helps in tracing the exact version of the agent code.
final String agentGitCommitSha;
/// Constructs a new `RepositoryInfo` instance.
///
/// [repoUrl]: The URL of the benchmark repository.
/// [teamName]: The name of the team responsible for the benchmark.
/// [benchmarkGitCommitSha]: The Git commit SHA for the benchmark.
/// [agentGitCommitSha]: The Git commit SHA for the agent.
RepositoryInfo({
required this.repoUrl,
required this.teamName,
required this.benchmarkGitCommitSha,
required this.agentGitCommitSha,
});
/// Creates a `RepositoryInfo` instance from a map.
///
/// [json]: A map containing key-value pairs corresponding to `RepositoryInfo` fields.
///
/// Returns a new `RepositoryInfo` populated with values from the map.
factory RepositoryInfo.fromJson(Map<String, dynamic> json) => RepositoryInfo(
repoUrl: json['repo_url'],
teamName: json['team_name'],
benchmarkGitCommitSha: json['benchmark_git_commit_sha'],
agentGitCommitSha: json['agent_git_commit_sha'],
);
/// Converts the `RepositoryInfo` instance to a map.
///
/// Returns a map containing key-value pairs corresponding to `RepositoryInfo` fields.
Map<String, dynamic> toJson() => {
'repo_url': repoUrl,
'team_name': teamName,
'benchmark_git_commit_sha': benchmarkGitCommitSha,
'agent_git_commit_sha': agentGitCommitSha,
};
}