Skip to content

Commit

Permalink
Add LocatorIds into the report page for asset analyzer command (#194)
Browse files Browse the repository at this point in the history
* Add LocatorIds into the report page for asset analyzer command

Description:

  When reporting the result to HTML page, to help customers to figure out the mapping
  between streaing Url on input asset and the streaming URL of the generated output asset,
  this change adds a new column in the report page to include LocatorIds for each input asset,
  if the locatorIds (Guid) are available.

  One input can have zero or multiple locatorIds, when it has multiple locatorIds, the report page uses
  ";\n" as a separator line between two locators.

  Adjust the percentage of each column in the report page, use it as guideline, the column length is not guaranteed
  if the asset name contains a word with a long list of characters without separators like ',-' etc.

  Some minor fix to make it report correct number of assets without locators.

* Update the AnalysisResult.LocatorIds property's type to List<string> instead a plain string

So that it is easier to work with both JSON and HTML report page.
  • Loading branch information
weibz authored Sep 26, 2023
1 parent 84bbed9 commit c1c0f7f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
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

0 comments on commit c1c0f7f

Please sign in to comment.