Skip to content
Open
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
6 changes: 6 additions & 0 deletions src/ByteSync.Client/Assets/Resources/Resources.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ Voulez-vous continuer ?</value>
<data name="InventoryProcess_IdentificationErrors" xml:space="preserve">
<value>Erreurs d'identification :</value>
</data>
<data name="InventoryProcess_SkippedEntries" xml:space="preserve">
<value>Entrées ignorées :</value>
</data>
<data name="InventoryProcess_Start" xml:space="preserve">
<value>Démarrage :</value>
</data>
Expand Down Expand Up @@ -670,6 +673,9 @@ Voulez-vous continuer ?</value>
<data name="InventoryProcess_GlobalAnalyzeErrors" xml:space="preserve">
<value>Total des erreurs de calcul :</value>
</data>
<data name="InventoryProcess_GlobalSkippedEntries" xml:space="preserve">
<value>Total des entrées ignorées :</value>
</data>
<data name="InventoryProcess_GlobalIdentificationErrors" xml:space="preserve">
<value>Total erreurs d'identification :</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions src/ByteSync.Client/Assets/Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ Would you like to continue ?</value>
<data name="InventoryProcess_IdentificationErrors" xml:space="preserve">
<value>Identification Errors:</value>
</data>
<data name="InventoryProcess_SkippedEntries" xml:space="preserve">
<value>Skipped Entries:</value>
</data>
<data name="InventoryProcess_Start" xml:space="preserve">
<value>Start:</value>
</data>
Expand Down Expand Up @@ -679,6 +682,9 @@ Would you like to continue ?</value>
<data name="InventoryProcess_GlobalAnalyzeErrors" xml:space="preserve">
<value>Total Calculation Errors:</value>
</data>
<data name="InventoryProcess_GlobalSkippedEntries" xml:space="preserve">
<value>Total Skipped Entries:</value>
</data>
<data name="InventoryProcess_GlobalIdentificationErrors" xml:space="preserve">
<value>Total Identification Errors:</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public record InventoryMonitorData
public long UploadTotalVolume { get; set; }

public long UploadedVolume { get; set; }

public int SkippedEntriesCount { get; set; }

public bool HasNonZeroProperty()
{
Expand All @@ -36,6 +38,7 @@ public bool HasNonZeroProperty()
|| AnalyzableVolume != 0
|| IdentifiedVolume != 0
|| UploadTotalVolume != 0
|| UploadedVolume != 0;
|| UploadedVolume != 0
|| SkippedEntriesCount != 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public void RecordSkippedEntry(SkippedEntry entry)
_skippedEntries.Enqueue(entry);
_skippedCountsByReason.AddOrUpdate(entry.Reason, 1, (_, currentCount) => currentCount + 1);
Interlocked.Increment(ref _skippedCount);
UpdateMonitorData(m => { m.SkippedEntriesCount += 1; });
}

// should be used during issue 268 implementation
Expand Down Expand Up @@ -182,4 +183,4 @@ private void ClearSkippedEntries()
_skippedCountsByReason.Clear();
Interlocked.Exchange(ref _skippedCount, 0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public record InventoryStatistics
public int AnalyzeErrors { get; init; }

public int IdentificationErrors { get; init; }

public int TotalSkippedEntries { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ private void DoCompute()
ProcessedVolume = statsCollector.ProcessedSize,
AnalyzeSuccess = statsCollector.Success,
AnalyzeErrors = statsCollector.Errors,
IdentificationErrors = statsCollector.IdentificationErrors
IdentificationErrors = statsCollector.IdentificationErrors,
TotalSkippedEntries = statsCollector.TotalSkippedEntries
};

_statisticsSubject.OnNext(stats);
Expand All @@ -81,6 +82,8 @@ private void ProcessInventoryFile(InventoryFile inventoryFile, StatisticsCollect

foreach (var part in inventory.InventoryParts)
{
collector.TotalSkippedEntries += part.SkippedCount;

foreach (var dir in part.DirectoryDescriptions)
{
if (!dir.IsAccessible)
Expand Down Expand Up @@ -142,6 +145,8 @@ private class StatisticsCollector
public int Errors { get; set; }

public int IdentificationErrors { get; set; }

public int TotalSkippedEntries { get; set; }

public long ProcessedSize { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ public InventoryGlobalStatusViewModel(IInventoryService inventoryService, ISessi

[Reactive]
public int? GlobalIdentificationErrors { get; set; }

[Reactive]
public int? GlobalSkippedEntries { get; set; }

public extern bool HasErrors { [ObservableAsProperty] get; }

public extern bool HasIdentificationErrors { [ObservableAsProperty] get; }

public extern bool ShowGlobalSkippedEntries { [ObservableAsProperty] get; }

[Reactive]
public string GlobalMainIcon { get; set; } = "None";
Expand Down Expand Up @@ -112,6 +117,11 @@ private void SetupBasicProperties(CompositeDisposable disposables)
.Select(e => (e ?? 0) > 0)
.ToPropertyEx(this, x => x.HasIdentificationErrors)
.DisposeWith(disposables);

this.WhenAnyValue(x => x.GlobalSkippedEntries)
.Select(e => (e ?? 0) > 0)
.ToPropertyEx(this, x => x.ShowGlobalSkippedEntries)
.DisposeWith(disposables);
}

private ReactiveStreams CreateStreams(IInventoryStatisticsService inventoryStatisticsService, CompositeDisposable disposables)
Expand Down Expand Up @@ -270,6 +280,7 @@ private void UpdateStatisticsValues(InventoryStatistics? stats)
GlobalAnalyzeSuccess = stats?.AnalyzeSuccess;
GlobalAnalyzeErrors = stats?.AnalyzeErrors;
GlobalIdentificationErrors = stats?.IdentificationErrors;
GlobalSkippedEntries = stats?.TotalSkippedEntries;
}

private void ApplySuccessState(int? errors, int? identificationErrors = null)
Expand Down Expand Up @@ -332,6 +343,7 @@ private void ResetStatistics()
GlobalAnalyzeSuccess = null;
GlobalAnalyzeErrors = null;
GlobalIdentificationErrors = null;
GlobalSkippedEntries = null;
GlobalMainIcon = "None";
GlobalMainStatusText = string.Empty;
GlobalMainIconBrush = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,19 @@ private void HandleActivation(CompositeDisposable disposables)
IdentifiedDirectories = m.IdentifiedDirectories;
IdentifiedVolume = m.IdentifiedVolume;
IdentificationErrors = m.IdentificationErrors;
SkippedEntriesCount = m.SkippedEntriesCount;
})
.DisposeWith(disposables);

this.WhenAnyValue(x => x.IdentificationErrors)
.Select(v => v > 0)
.ToPropertyEx(this, x => x.HasIdentificationErrors)
.DisposeWith(disposables);

this.WhenAnyValue(x => x.SkippedEntriesCount)
.Select(v => v > 0)
.ToPropertyEx(this, x => x.ShowSkippedEntriesCount)
.DisposeWith(disposables);

_inventoryService.InventoryProcessData.IdentificationStatus
.ObserveOn(RxApp.MainThreadScheduler)
Expand Down Expand Up @@ -133,8 +139,13 @@ private void HandleActivation(CompositeDisposable disposables)

[Reactive]
public int IdentificationErrors { get; set; }

public extern bool HasIdentificationErrors { [ObservableAsProperty] get; }

[Reactive]
public int SkippedEntriesCount { get; set; }

public extern bool ShowSkippedEntriesCount { [ObservableAsProperty] get; }

[Reactive]
public string IdentificationIcon { get; set; } = "None";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>

<Label Grid.Row="0" Grid.Column="0" Content="{localizations:Loc InventoryProcess_GlobalAnalyzedFiles}"
Expand Down Expand Up @@ -97,6 +98,15 @@
<TextBlock Text="{Binding GlobalAnalyzeErrors, FallbackValue=''}"
Classes.IsBold="{Binding HasErrors}" />
</Border>

<Label Grid.Row="5" Grid.Column="0" Content="{localizations:Loc InventoryProcess_GlobalSkippedEntries}"
Classes="InventoryStatusDescription"
IsVisible="{Binding ShowGlobalSkippedEntries}" />
<Border Grid.Row="5" Grid.Column="1" HorizontalAlignment="Right"
Classes="Badge"
IsVisible="{Binding ShowGlobalSkippedEntries}">
<TextBlock Text="{Binding GlobalSkippedEntries, FallbackValue=''}" />
</Border>
</Grid>
</WrapPanel>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>

<Label Grid.Row="0" Grid.Column="0" Content="{localizations:Loc InventoryProcess_IdentifiedFiles}"
Expand Down Expand Up @@ -70,6 +71,15 @@
<TextBlock Text="{Binding IdentificationErrors, FallbackValue=0}"
Classes.IsBold="{Binding HasIdentificationErrors}" />
</Border>

<Label Grid.Row="4" Grid.Column="0" Content="{localizations:Loc InventoryProcess_SkippedEntries}"
Classes="InventoryStatusDescription"
IsVisible="{Binding ShowSkippedEntriesCount}" />
<Border Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right"
Classes="Badge"
IsVisible="{Binding ShowSkippedEntriesCount}">
<TextBlock Text="{Binding SkippedEntriesCount, FallbackValue=0}" />
</Border>
</Grid>
</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ public void HasNonZeroProperty_WithUploadedVolume_ShouldReturnTrue()
// Assert
result.Should().BeTrue();
}

[Test]
public void HasNonZeroProperty_WithSkippedEntriesCount_ShouldReturnTrue()
{
// Arrange
var data = new InventoryMonitorData { SkippedEntriesCount = 2 };

// Act
var result = data.HasNonZeroProperty();

// Assert
result.Should().BeTrue();
}

[Test]
public void HasNonZeroProperty_WithMultipleNonZeroProperties_ShouldReturnTrue()
Expand Down Expand Up @@ -201,4 +214,4 @@ public void UploadTotalVolume_ShouldBeSettableAndGettable()
// Assert
data.UploadTotalVolume.Should().Be(10240);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reactive.Linq;
using ByteSync.Business.Inventories;
using ByteSync.Models.Inventories;
using FluentAssertions;
Expand Down Expand Up @@ -44,6 +45,21 @@ public void RecordSkippedEntry_ShouldUpdateGlobalAndReasonCounters()
data.GetSkippedCountByReason(SkipReason.NoiseEntry).Should().Be(1);
data.GetSkippedCountByReason(SkipReason.Offline).Should().Be(0);
}

[Test]
public async Task RecordSkippedEntry_ShouldUpdateMonitorSkippedEntriesCount()
{
// Arrange
var data = new InventoryProcessData();

// Act
data.RecordSkippedEntry(new SkippedEntry { Reason = SkipReason.Hidden });
data.RecordSkippedEntry(new SkippedEntry { Reason = SkipReason.NoiseEntry });
var monitor = await data.InventoryMonitorObservable.FirstAsync();

// Assert
monitor.SkippedEntriesCount.Should().Be(2);
}

[Test]
public void Reset_ShouldClearSkippedEntriesAndCounters()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static string CreateInventoryZip(Inventory inventory)
}

private static Inventory BuildInventoryWithFiles(int successCount, int errorCount, int neutralCount,
int inaccessibleFiles = 0, int inaccessibleDirectories = 0)
int inaccessibleFiles = 0, int inaccessibleDirectories = 0, int skippedHidden = 0, int skippedNoise = 0)
{
var inv = new Inventory
{
Expand Down Expand Up @@ -122,6 +122,16 @@ private static Inventory BuildInventoryWithFiles(int successCount, int errorCoun
};
part.DirectoryDescriptions.Add(dir);
}

for (var i = 0; i < skippedHidden; i++)
{
part.RecordSkippedEntry(SkipReason.Hidden);
}

for (var i = 0; i < skippedNoise; i++)
{
part.RecordSkippedEntry(SkipReason.NoiseEntry);
}

return inv;
}
Expand Down Expand Up @@ -167,6 +177,7 @@ public async Task Compute_WithSingleInventory_ComputesExpectedTotals()
stats.AnalyzeSuccess.Should().Be(3);
stats.AnalyzeErrors.Should().Be(2);
stats.IdentificationErrors.Should().Be(0);
stats.TotalSkippedEntries.Should().Be(0);
}
finally
{
Expand Down Expand Up @@ -229,6 +240,7 @@ public async Task Compute_WithMultipleInventories_AggregatesAll()
stats.AnalyzeSuccess.Should().Be(1 + 2);
stats.AnalyzeErrors.Should().Be(1 + 0);
stats.IdentificationErrors.Should().Be(0);
stats.TotalSkippedEntries.Should().Be(0);
}
finally
{
Expand Down Expand Up @@ -286,6 +298,55 @@ public async Task Compute_CountsIdentificationErrors()
stats.AnalyzeSuccess.Should().Be(0);
stats.AnalyzeErrors.Should().Be(0);
stats.IdentificationErrors.Should().Be(3);
stats.TotalSkippedEntries.Should().Be(0);
}
finally
{
if (File.Exists(zip))
{
File.Delete(zip);
}
}
}

[Test]
public async Task Compute_CountsSkippedEntriesFromInventoryParts()
{
var inv = BuildInventoryWithFiles(successCount: 0, errorCount: 0, neutralCount: 0, skippedHidden: 2, skippedNoise: 1);
var zip = CreateInventoryZip(inv);

try
{
var sfd = new SharedFileDefinition
{
SessionId = "S",
ClientInstanceId = inv.Endpoint.ClientInstanceId,
SharedFileType = SharedFileTypes.FullInventory,
AdditionalName = inv.CodeAndId,
IV = new byte[16]
};
var inventoryFile = new InventoryFile(sfd, zip);

var repo = new Mock<IInventoryFileRepository>();
repo.Setup(r => r.GetAllInventoriesFiles(LocalInventoryModes.Full))
.Returns([inventoryFile]);

var ipd = new InventoryProcessData();
var invService = new Mock<IInventoryService>();
invService.SetupGet(s => s.InventoryProcessData).Returns(ipd);

var logger = new Mock<ILogger<InventoryStatisticsService>>();

var service = new InventoryStatisticsService(invService.Object, repo.Object, logger.Object);

var tcs = new TaskCompletionSource<InventoryStatistics>();
using var sub = service.Statistics.Where(s => s != null).Take(1).Select(s => s!).Subscribe(s => tcs.TrySetResult(s));

ipd.AreFullInventoriesComplete.OnNext(true);

var stats = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));

stats.TotalSkippedEntries.Should().Be(3);
}
finally
{
Expand Down
Loading
Loading