Optimized code

This commit is contained in:
Thorsten Sommer 2026-02-08 17:40:19 +01:00
parent 4eb58eb56d
commit 34317fc219
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 11 additions and 14 deletions

View File

@ -24,7 +24,7 @@
<MudText Typo="Typo.body1">
@this.VersionDatabase
</MudText>
<MudCollapse Expanded="@showDatabaseDetails">
<MudCollapse Expanded="@this.showDatabaseDetails">
<MudText Typo="Typo.body1" Class="mt-2 mb-2">
@foreach (var item in this.databaseDisplayInfo)
{

View File

@ -5,12 +5,12 @@ public abstract class DatabaseClient(string name, string path)
public string Name => name;
private string Path => path;
protected ILogger<DatabaseClient>? logger;
private ILogger<DatabaseClient>? logger;
public abstract IAsyncEnumerable<(string Label, string Value)> GetDisplayInfo();
public string GetStorageSize()
protected string GetStorageSize()
{
if (string.IsNullOrWhiteSpace(this.Path))
{
@ -28,8 +28,8 @@ public abstract class DatabaseClient(string name, string path)
var size = files.Sum(file => new FileInfo(file).Length);
return FormatBytes(size);
}
public static string FormatBytes(long size)
private static string FormatBytes(long size)
{
string[] suffixes = { "B", "KB", "MB", "GB", "TB", "PB" };
int suffixIndex = 0;

View File

@ -25,8 +25,8 @@ public class QdrantClientImplementation : DatabaseClient
}
private const string IP_ADDRESS = "localhost";
public QdrantClient CreateQdrantClient()
private QdrantClient CreateQdrantClient()
{
var address = "https://" + IP_ADDRESS + ":" + this.GrpcPort;
var channel = QdrantChannel.ForAddress(address, new ClientConfiguration
@ -38,13 +38,13 @@ public class QdrantClientImplementation : DatabaseClient
return new QdrantClient(grpcClient);
}
public async Task<string> GetVersion()
private async Task<string> GetVersion()
{
var operation = await this.GrpcClient.HealthAsync();
return "v"+operation.Version;
}
public async Task<string> GetCollectionsAmount()
private async Task<string> GetCollectionsAmount()
{
var operation = await this.GrpcClient.ListCollectionsAsync();
return operation.Count.ToString();
@ -59,8 +59,5 @@ public class QdrantClientImplementation : DatabaseClient
yield return ("Amount of collections", await this.GetCollectionsAmount());
}
public override void Dispose()
{
this.GrpcClient.Dispose();
}
public override void Dispose() => this.GrpcClient.Dispose();
}