Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LocatorIds into the report page for asset analyzer command #194

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion ams/AssetAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public AssetAnalyzer(

private async Task<AnalysisResult> AnalyzeAsync(MediaAssetResource asset, BlobServiceClient storage, CancellationToken cancellationToken)
{
var result = new AnalysisResult(asset.Data.Name, MigrationStatus.NotMigrated, 0);
var result = new AnalysisResult(asset.Data.Name, MigrationStatus.NotMigrated);
_logger.LogDebug("Analyzing asset: {asset}, container: {container}", asset.Data.Name, asset.Data.Container);
try
{
Expand All @@ -44,6 +44,17 @@ private async Task<AnalysisResult> AnalyzeAsync(MediaAssetResource asset, BlobSe
return result;
}

// Get a list of LocatorIds if they exist.
var locators = asset.GetStreamingLocatorsAsync();

await foreach (var locator in locators)
{
if (locator.StreamingLocatorId != null && locator.StreamingLocatorId != Guid.Empty)
{
result.LocatorIds.Add(locator.StreamingLocatorId.Value.ToString("D"));
}
}

// The asset container exists, try to check the metadata list first.
var migrateResult = await _tracker.GetMigrationStatusAsync(container, cancellationToken);

Expand Down
2 changes: 1 addition & 1 deletion ams/AssetStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void Update(AnalysisResult result)
Interlocked.Increment(ref _streamable);
}

if (result.Locators == 0)
if (result.LocatorIds.Count == 0)
{
Interlocked.Increment(ref _noLocators);
}
Expand Down
23 changes: 18 additions & 5 deletions ams/ReportGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ public void WriteHeader()
<table>
<thead>
<tr>
<th style=""width:15%"">Asset Name</t>
<th style=""width:10%"">Asset Name</t>
<th style=""width:5%"">AssetType</th>
<th style=""width:8%"">MigrateStatus</th>
<th style=""width:36%"">OutputHlsUrl</th>
<th style=""width:36%"">OutputDashUrl</th>
<th style=""width:10%"">LocatorIds</th>
<th style=""width:7%"">MigrateStatus</th>
<th style=""width:34%"">OutputHlsUrl</th>
<th style=""width:34%"">OutputDashUrl</th>
</tr>
</thead>
<tbody>");
Expand All @@ -69,7 +70,19 @@ public void WriteRow(AnalysisResult result)
{
lock (this)
{
_writer.Write($"<tr><td>{result.AssetName}</td><td>{result.AssetType}</td><td>{result.Status}</td><td>");
string locatorIds = "";

foreach (var locId in result.LocatorIds)
{
if (!string.IsNullOrEmpty(locatorIds))
{
locatorIds += ";\n";
}

locatorIds += locId;
}

_writer.Write($"<tr><td>{result.AssetName}</td><td>{result.AssetType}</td><td>{locatorIds}</td><td>{result.Status}</td><td>");
if (result.OutputHlsUrl != null)
_writer.Write($"<a href=\"{result.OutputHlsUrl}\">{result.OutputHlsUrl}</a>");

Expand Down
9 changes: 6 additions & 3 deletions transform/AnalyzeTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ namespace AMSMigrate.Transform
{
class AnalysisResult : AssetMigrationResult
{
public AnalysisResult(string assetName, MigrationStatus status, int locators, Uri? outputPath = null, string? assetType = null, string? manifestName = null)
public AnalysisResult(string assetName, MigrationStatus status, Uri? outputPath = null, string? assetType = null, string? manifestName = null)
: base(status, outputPath, assetType, manifestName)
{
AssetName = assetName;
Locators = locators;

LocatorIds = new List<string>();
}

public int Locators { get; internal set; }
// A list of Locator Guids of the asset,
// it can have zero or multiple GUIDs.
public List<string> LocatorIds { get; }

public string AssetName { get; set; }

Expand Down
Loading