Skip to content

Commit

Permalink
fix(cli): missing force analyze option in xlsx
Browse files Browse the repository at this point in the history
  • Loading branch information
akiver committed Jul 15, 2022
1 parent 2c50ee3 commit 7dd0df6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CLI/XlsxCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private async Task ProcessSingleFileExport()
DemoPaths = _demoPaths,
FocusSteamId = _focusSteamId,
Source = _source,
ForceAnalyze = _forceAnalyze,
OnProcessingDemo = (demoPath, demoNumber, totalDemoCount) => Console.WriteLine($@"Retrieving demo {demoNumber}/{totalDemoCount} {demoPath}"),
OnDemoNotFound = demoPath => Console.WriteLine($@"The demo doesn't exists: {demoPath}"),
OnInvalidDemo = demoPath => Console.WriteLine($@"Invalid demo {demoPath}"),
Expand All @@ -122,6 +123,7 @@ private async Task ProcessMultipleFilesExport()
{
try
{
Console.WriteLine($@"Retrieving demo {++currentDemoNumber}/{_demoPaths.Count} {demoPath}");
string outputFolderPath = BuildOutputFolderPathFromDemoPath(demoPath);
string demoName = Path.GetFileName(demoPath);
string fileName = outputFolderPath + Path.DirectorySeparatorChar + demoName + ".xlsx";
Expand All @@ -131,7 +133,6 @@ private async Task ProcessMultipleFilesExport()
FileName = fileName,
Source = _source,
ForceAnalyze = _forceAnalyze,
OnProcessingDemo = () => Console.WriteLine($@"Retrieving demo {++currentDemoNumber}/{_demoPaths.Count} {demoPath}"),
OnAnalyzeStart = () => Console.WriteLine($@"Analyzing demo {demoPath}"),
};
await _excelService.GenerateXls(configuration);
Expand Down
2 changes: 1 addition & 1 deletion Services/Concrete/Excel/MultipleExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override async Task<IWorkbook> Generate()
continue;
}

if (!_configuration.ForceAnalyze && !_cacheService.HasDemoInCache(demo.Id))
if (_configuration.ForceAnalyze || !_cacheService.HasDemoInCache(demo.Id))
{
try
{
Expand Down
18 changes: 9 additions & 9 deletions Services/Concrete/Excel/SingleExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,17 @@ public SingleExport(SingleExportConfiguration configuration)
public override async Task<IWorkbook> Generate()
{
CancellationToken cancellationToken = _configuration.CancellationToken.Token;
_configuration.OnProcessingDemo?.Invoke();
Demo demo = DemoAnalyzer.ParseDemoHeader(_configuration.DemoPath);
if (demo == null)
{
throw new InvalidDemoException();
}

if (!_configuration.ForceAnalyze && _cacheService.HasDemoInCache(demo.Id))
{
demo = await _cacheService.GetDemoDataFromCache(demo.Id);
demo.WeaponFired = await _cacheService.GetDemoWeaponFiredAsync(demo);
demo.PlayerBlinded = await _cacheService.GetDemoPlayerBlindedAsync(demo);
cancellationToken.ThrowIfCancellationRequested();
}
else
if (_configuration.ForceAnalyze || !_cacheService.HasDemoInCache(demo.Id))
{
try
{
_configuration.OnAnalyzeStart?.Invoke();
DemoAnalyzer analyzer = DemoAnalyzer.Factory(demo);
if (_configuration.Source != null)
{
Expand All @@ -88,6 +81,13 @@ public override async Task<IWorkbook> Generate()
throw new AnalyzeException(ex);
}
}
else
{
demo = await _cacheService.GetDemoDataFromCache(demo.Id);
demo.WeaponFired = await _cacheService.GetDemoWeaponFiredAsync(demo);
demo.PlayerBlinded = await _cacheService.GetDemoPlayerBlindedAsync(demo);
cancellationToken.ThrowIfCancellationRequested();
}

_generalSheet = new GeneralSheet(Workbook, demo);
_generalSheet.Generate();
Expand Down

0 comments on commit 7dd0df6

Please sign in to comment.