feat(app): add get all addresses feature
This commit is contained in:
@@ -60,12 +60,13 @@ while (true)
|
||||
Console.WriteLine("Options:");
|
||||
Console.WriteLine(" 1. Add a new address");
|
||||
Console.WriteLine(" 2. Search for similar addresses");
|
||||
Console.WriteLine(" 3. Exit");
|
||||
Console.WriteLine(" 3. Get all addresses");
|
||||
Console.WriteLine(" 4. Exit");
|
||||
Console.Write("Select an option: ");
|
||||
|
||||
var option = Console.ReadLine()?.Trim();
|
||||
|
||||
if (option?.ToLower() == "exit" || option == "3")
|
||||
if (option?.ToLower() == "exit" || option == "4")
|
||||
{
|
||||
Console.WriteLine("Goodbye!");
|
||||
return;
|
||||
@@ -79,6 +80,9 @@ while (true)
|
||||
case "2":
|
||||
await SearchAddressesAsync(embeddingService, qdrantService, appConfig);
|
||||
break;
|
||||
case "3":
|
||||
await GetAllAddressesAsync(qdrantService);
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Invalid option. Please try again.");
|
||||
break;
|
||||
@@ -196,4 +200,35 @@ async Task SearchAddressesAsync(IEmbeddingService embeddingService, IQdrantServi
|
||||
{
|
||||
Console.WriteLine($"Error during search: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
async Task GetAllAddressesAsync(IQdrantService? qdrantService)
|
||||
{
|
||||
if (qdrantService == null)
|
||||
{
|
||||
Console.WriteLine("Getting all addresses is not available because Qdrant is not connected.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Retrieving all addresses...");
|
||||
var addresses = await qdrantService.GetAllAddressesAsync();
|
||||
|
||||
if (addresses.Count == 0)
|
||||
{
|
||||
Console.WriteLine("No addresses found in the database.");
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine($"\nFound {addresses.Count} address(es):");
|
||||
for (int i = 0; i < addresses.Count; i++)
|
||||
{
|
||||
Console.WriteLine($" {i + 1}. {addresses[i].FullAddress}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error retrieving addresses: {ex.Message}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user