mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Fix charts crashing on initialization.
This commit is contained in:
@@ -15,6 +15,7 @@ public partial class Devices
|
|||||||
List<long> _devicesByManufacturerCounts = [];
|
List<long> _devicesByManufacturerCounts = [];
|
||||||
string[] _devicesByManufacturerLabels = [];
|
string[] _devicesByManufacturerLabels = [];
|
||||||
Carousel? _devicesCarousel;
|
Carousel? _devicesCarousel;
|
||||||
|
bool _isAlreadyInitialized;
|
||||||
List<DeviceItem> DevicesList { get; set; } = [];
|
List<DeviceItem> DevicesList { get; set; } = [];
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -29,6 +30,15 @@ public partial class Devices
|
|||||||
.ThenBy(static device => device.Revision)
|
.ThenBy(static device => device.Revision)
|
||||||
.ThenBy(static device => device.Bus)
|
.ThenBy(static device => device.Bus)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if(_isAlreadyInitialized) return;
|
||||||
|
|
||||||
|
_isAlreadyInitialized = true;
|
||||||
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
var data = await ctx.DeviceStats.Select(static d => d.Bus)
|
var data = await ctx.DeviceStats.Select(static d => d.Bus)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ public partial class Filesystems
|
|||||||
PieChart<long>? _filesystemsChart;
|
PieChart<long>? _filesystemsChart;
|
||||||
List<long> _filesystemsCounts = [];
|
List<long> _filesystemsCounts = [];
|
||||||
string[] _filesystemsLabels = [];
|
string[] _filesystemsLabels = [];
|
||||||
|
bool _isAlreadyInitialized;
|
||||||
List<Filesystem> FilesystemsList { get; set; } = [];
|
List<Filesystem> FilesystemsList { get; set; } = [];
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -20,6 +21,15 @@ public partial class Filesystems
|
|||||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
FilesystemsList = await ctx.Filesystems.OrderBy(static filesystem => filesystem.Name).ToListAsync();
|
FilesystemsList = await ctx.Filesystems.OrderBy(static filesystem => filesystem.Name).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if(_isAlreadyInitialized) return;
|
||||||
|
|
||||||
|
_isAlreadyInitialized = true;
|
||||||
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
_filesystemsLabels = await ctx.Filesystems.OrderByDescending(static o => o.Count)
|
_filesystemsLabels = await ctx.Filesystems.OrderByDescending(static o => o.Count)
|
||||||
.Take(10)
|
.Take(10)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ public partial class Filters
|
|||||||
PieChart<long>? _filtersChart;
|
PieChart<long>? _filtersChart;
|
||||||
List<long> _filtersCounts = [];
|
List<long> _filtersCounts = [];
|
||||||
string[] _filtersLabels = [];
|
string[] _filtersLabels = [];
|
||||||
|
bool _isAlreadyInitialized;
|
||||||
List<Filter> FiltersList { get; set; } = [];
|
List<Filter> FiltersList { get; set; } = [];
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -20,6 +21,15 @@ public partial class Filters
|
|||||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
FiltersList = await ctx.Filters.OrderBy(static filter => filter.Name).ToListAsync();
|
FiltersList = await ctx.Filters.OrderBy(static filter => filter.Name).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if(_isAlreadyInitialized) return;
|
||||||
|
|
||||||
|
_isAlreadyInitialized = true;
|
||||||
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
_filtersLabels = await ctx.Filters.OrderByDescending(static o => o.Count)
|
_filtersLabels = await ctx.Filters.OrderByDescending(static o => o.Count)
|
||||||
.Take(10)
|
.Take(10)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ public partial class Formats
|
|||||||
PieChart<long>? _formatsChart;
|
PieChart<long>? _formatsChart;
|
||||||
List<long> _formatsCounts = [];
|
List<long> _formatsCounts = [];
|
||||||
string[] _formatsLabels = [];
|
string[] _formatsLabels = [];
|
||||||
|
bool _isAlreadyInitialized;
|
||||||
List<MediaFormat> MediaImages { get; set; } = [];
|
List<MediaFormat> MediaImages { get; set; } = [];
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -18,7 +19,15 @@ public partial class Formats
|
|||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
|
|
||||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if(_isAlreadyInitialized) return;
|
||||||
|
|
||||||
|
_isAlreadyInitialized = true;
|
||||||
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
MediaImages = await ctx.MediaFormats.OrderBy(static format => format.Name).ToListAsync();
|
MediaImages = await ctx.MediaFormats.OrderBy(static format => format.Name).ToListAsync();
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace Aaru.Server.Components.Pages.Statistics;
|
|||||||
|
|
||||||
public partial class OperatingSystems
|
public partial class OperatingSystems
|
||||||
{
|
{
|
||||||
|
bool _isAlreadyInitialized;
|
||||||
PieChart<long>? _linuxChart;
|
PieChart<long>? _linuxChart;
|
||||||
List<long> _linuxCounts = [];
|
List<long> _linuxCounts = [];
|
||||||
string[] _linuxLabels = [];
|
string[] _linuxLabels = [];
|
||||||
@@ -43,6 +44,17 @@ public partial class OperatingSystems
|
|||||||
})
|
})
|
||||||
.ToListAsync()).OrderBy(static os => os.name)
|
.ToListAsync()).OrderBy(static os => os.name)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if(_isAlreadyInitialized) return;
|
||||||
|
|
||||||
|
_isAlreadyInitialized = true;
|
||||||
|
|
||||||
|
// TODO: Cache real OS name in database, lookups would be much faster
|
||||||
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
var osQuery = ctx.OperatingSystems.GroupBy(static x => new
|
var osQuery = ctx.OperatingSystems.GroupBy(static x => new
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace Aaru.Server.Components.Pages.Statistics;
|
|||||||
|
|
||||||
public partial class Partitions
|
public partial class Partitions
|
||||||
{
|
{
|
||||||
|
bool _isAlreadyInitialized;
|
||||||
PieChart<long>? _partitionsChart;
|
PieChart<long>? _partitionsChart;
|
||||||
List<long> _partitionsCounts = [];
|
List<long> _partitionsCounts = [];
|
||||||
string[] _partitionsLabels = [];
|
string[] _partitionsLabels = [];
|
||||||
@@ -18,6 +19,15 @@ public partial class Partitions
|
|||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
|
|
||||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if(_isAlreadyInitialized) return;
|
||||||
|
|
||||||
|
_isAlreadyInitialized = true;
|
||||||
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
PartitionsList = await ctx.Partitions.OrderBy(static partition => partition.Name).ToListAsync();
|
PartitionsList = await ctx.Partitions.OrderBy(static partition => partition.Name).ToListAsync();
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace Aaru.Server.Components.Pages.Statistics;
|
|||||||
|
|
||||||
public partial class RealMedias
|
public partial class RealMedias
|
||||||
{
|
{
|
||||||
|
bool _isAlreadyInitialized;
|
||||||
PieChart<long>? _realMediaChart;
|
PieChart<long>? _realMediaChart;
|
||||||
List<long> _realMediaCounts = [];
|
List<long> _realMediaCounts = [];
|
||||||
string[] _realMediaLabels = [];
|
string[] _realMediaLabels = [];
|
||||||
@@ -20,6 +21,15 @@ public partial class RealMedias
|
|||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
|
|
||||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if(_isAlreadyInitialized) return;
|
||||||
|
|
||||||
|
_isAlreadyInitialized = true;
|
||||||
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
Media[] realMedias = await ctx.Medias.Where(static o => o.Real)
|
Media[] realMedias = await ctx.Medias.Where(static o => o.Real)
|
||||||
.OrderByDescending(static o => o.Count)
|
.OrderByDescending(static o => o.Count)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace Aaru.Server.Components.Pages.Statistics;
|
|||||||
|
|
||||||
public partial class Versions
|
public partial class Versions
|
||||||
{
|
{
|
||||||
|
bool _isAlreadyInitialized;
|
||||||
PieChart<long>? _versionsChart;
|
PieChart<long>? _versionsChart;
|
||||||
List<long> _versionsCounts = [];
|
List<long> _versionsCounts = [];
|
||||||
string[] _versionsLabels = [];
|
string[] _versionsLabels = [];
|
||||||
@@ -26,6 +27,15 @@ public partial class Versions
|
|||||||
})
|
})
|
||||||
.ToListAsync()).OrderBy(static version => version.name)
|
.ToListAsync()).OrderBy(static version => version.name)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if(_isAlreadyInitialized) return;
|
||||||
|
|
||||||
|
_isAlreadyInitialized = true;
|
||||||
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
_versionsLabels = await ctx.Versions.OrderByDescending(static o => o.Count)
|
_versionsLabels = await ctx.Versions.OrderByDescending(static o => o.Count)
|
||||||
.Take(10)
|
.Take(10)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace Aaru.Server.Components.Pages.Statistics;
|
|||||||
|
|
||||||
public partial class VirtualMedias
|
public partial class VirtualMedias
|
||||||
{
|
{
|
||||||
|
bool _isAlreadyInitialized;
|
||||||
PieChart<long>? _virtualMediaChart;
|
PieChart<long>? _virtualMediaChart;
|
||||||
List<long> _virtualMediaCounts = [];
|
List<long> _virtualMediaCounts = [];
|
||||||
string[] _virtualMediaLabels = [];
|
string[] _virtualMediaLabels = [];
|
||||||
@@ -20,6 +21,15 @@ public partial class VirtualMedias
|
|||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
|
|
||||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if(_isAlreadyInitialized) return;
|
||||||
|
|
||||||
|
_isAlreadyInitialized = true;
|
||||||
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
Media[] virtualMedias = await ctx.Medias.Where(static o => !o.Real)
|
Media[] virtualMedias = await ctx.Medias.Where(static o => !o.Real)
|
||||||
.OrderByDescending(static o => o.Count)
|
.OrderByDescending(static o => o.Count)
|
||||||
|
|||||||
Reference in New Issue
Block a user