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

View File

@ -6,11 +6,11 @@ public abstract class DatabaseClient(string name, string path)
private string Path => path; private string Path => path;
protected ILogger<DatabaseClient>? logger; private ILogger<DatabaseClient>? logger;
public abstract IAsyncEnumerable<(string Label, string Value)> GetDisplayInfo(); public abstract IAsyncEnumerable<(string Label, string Value)> GetDisplayInfo();
public string GetStorageSize() protected string GetStorageSize()
{ {
if (string.IsNullOrWhiteSpace(this.Path)) if (string.IsNullOrWhiteSpace(this.Path))
{ {
@ -29,7 +29,7 @@ public abstract class DatabaseClient(string name, string path)
return FormatBytes(size); return FormatBytes(size);
} }
public static string FormatBytes(long size) private static string FormatBytes(long size)
{ {
string[] suffixes = { "B", "KB", "MB", "GB", "TB", "PB" }; string[] suffixes = { "B", "KB", "MB", "GB", "TB", "PB" };
int suffixIndex = 0; int suffixIndex = 0;

View File

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