34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using System.CommandLine;
|
|
using Gpulse.WCT.DataAnalyzer.Core.Application;
|
|
|
|
namespace Gpulse.WCT.DataAnalyzer.Commands;
|
|
|
|
/// <summary>
|
|
/// 从本地解析库生成正式发布库。
|
|
/// </summary>
|
|
public class AggregateCommand : Command
|
|
{
|
|
public AggregateCommand(AggregationService aggregationService)
|
|
: base("aggregate", "Aggregate local log data into the release database")
|
|
{
|
|
var rebuildOption = new Option<bool>(
|
|
"--rebuild",
|
|
() => true,
|
|
"Rebuild the release table before inserting aggregated records");
|
|
AddOption(rebuildOption);
|
|
|
|
this.SetHandler(async rebuild =>
|
|
{
|
|
try
|
|
{
|
|
var report = await aggregationService.AggregateAsync(rebuild);
|
|
Console.WriteLine($"Aggregated {report.LocalRecordCount} local Ploss records into {report.ReleaseRecordCount} release records.");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Aggregation failed: {ex.Message}");
|
|
}
|
|
}, rebuildOption);
|
|
}
|
|
}
|