Skip to content

Commit

Permalink
✨ Implement ICacheableResource for JobHostSummary
Browse files Browse the repository at this point in the history
  • Loading branch information
teramako committed Jan 21, 2025
1 parent 118adb7 commit 9f3f3fa
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Jagabata/Resources/JobHostSummary.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Specialized;
using System.Text;

namespace Jagabata.Resources
{
Expand All @@ -7,7 +8,7 @@ public class JobHostSummary(ulong id, ResourceType type, string url, RelatedDict
DateTime created, DateTime? modified, ulong job, ulong host, ulong? constructedHost,
string hostName, int changed, int dark, int failures, int oK, int processed, int skipped,
bool failed, int ignored, int rescued)
: IResource
: IResource, ICacheableResource
{
public const string PATH = "/api/v2/job_host_summaries/";
/// <summary>
Expand Down Expand Up @@ -105,5 +106,18 @@ public static async IAsyncEnumerable<JobHostSummary> FindFromJob(ulong jobId,
public bool Failed { get; } = failed;
public int Ignored { get; } = ignored;
public int Rescued { get; } = rescued;

public string GetDescription()
{
var sb = new StringBuilder($"[{ResourceType.Host}:{Host}] {HostName}");
if (SummaryFields.TryGetValue("Job", out var j) && j is JobExSummary job)
{
sb.Append($" Job=[{job.Id}]{job.Name}")
.Append($" Status={job.Status}")
.Append($" Elapsed={job.Elapsed}")
.Append($" JobTemplate=[{job.JobTemplateId}]{job.JobTemplateName}");
}
return sb.ToString();
}
}
}

0 comments on commit 9f3f3fa

Please # to comment.