Skip to content

Commit

Permalink
More work in support of #474.
Browse files Browse the repository at this point in the history
  • Loading branch information
uncheckederror committed Nov 8, 2024
1 parent 19acb5b commit 50c737f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
4 changes: 2 additions & 2 deletions NumberSearch.Ingest/Orders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public static async Task<bool> DailyBriefingEmailAsync(Owned.SMSRouteChange[] sm
var failedMessages = Array.Empty<MessageRecord>();

var token = await GetTokenAsync(appConfig);
failedMessages = await $"{appConfig.MessagingURL}message/all/failed?start={DateTime.Now.AddDays(-3).ToShortDateString()}&end={DateTime.Now.AddDays(1).ToShortDateString()}".WithOAuthBearerToken(token.AccessToken).GetJsonAsync<MessageRecord[]>();

var messages = await $"{appConfig.MessagingURL}message/all/failed?start={DateTime.Now.AddDays(-3).ToShortDateString()}&end={DateTime.Now.AddDays(1).ToShortDateString()}".WithOAuthBearerToken(token.AccessToken).GetJsonAsync<MessageRecord[]>();
failedMessages = messages.Where(x => x.MessageSource is MessageSource.Outgoing).ToArray();
foreach (var order in orders)
{
// Orders that should be marked as complete because the install data has passed?
Expand Down
4 changes: 1 addition & 3 deletions NumberSearch.Ingest/Provider.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FirstCom;
using FirstCom.Models;
using FirstCom.Models;

using NumberSearch.DataAccess;
using NumberSearch.DataAccess.BulkVS;
Expand All @@ -9,7 +8,6 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;

Expand Down
1 change: 1 addition & 0 deletions NumberSearch.Mvc/Controllers/CartController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public async Task<IActionResult> IndexAsync(bool? emptyCart, string product, int
var cordless = cart.Products.Where(x => x.Name.Contains("DP")).ToArray();
int handsets = 0;
int basestations = 0;

foreach (var item in cordless)
{
var productOrder = cart?.ProductOrders?.FirstOrDefault(x => x.ProductId == item.ProductId);
Expand Down
18 changes: 9 additions & 9 deletions NumberSearch.Mvc/Controllers/SearchController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public async Task<IActionResult> SearchAsync(string query, string city, string f
}

// If there's a city provided we need to use a more specific results count query.
var count = (string.IsNullOrWhiteSpace(city))
? await PhoneNumber.NumberOfResultsInQuery(cleanedQuery, _postgresql).ConfigureAwait(false)
: await PhoneNumber.NumberOfResultsInQueryWithCity(cleanedQuery, city, _postgresql).ConfigureAwait(false);
int count = string.IsNullOrWhiteSpace(city)
? await PhoneNumber.NumberOfResultsInQuery(cleanedQuery, _postgresql)
: await PhoneNumber.NumberOfResultsInQueryWithCity(cleanedQuery, city, _postgresql);

// Handle out of range page values.
page = page < 1 ? 1 : page;
Expand All @@ -90,30 +90,30 @@ public async Task<IActionResult> SearchAsync(string query, string city, string f
// Select a view for the data.
if (!string.IsNullOrWhiteSpace(view) && view == "Recommended")
{
results = await PhoneNumber.RecommendedPaginatedSearchAsync(cleanedQuery, page, _postgresql).ConfigureAwait(false);
results = await PhoneNumber.RecommendedPaginatedSearchAsync(cleanedQuery, page, _postgresql);
}
else if (!string.IsNullOrWhiteSpace(view) && view == "Sequential")
{
results = await PhoneNumber.SequentialPaginatedSearchAsync(cleanedQuery, page, _postgresql).ConfigureAwait(false);
results = await PhoneNumber.SequentialPaginatedSearchAsync(cleanedQuery, page, _postgresql);
}
else if (!string.IsNullOrWhiteSpace(view) && view == "Location")
{
// If a city is provided then we need to filter our results down to just that city.
if (!string.IsNullOrWhiteSpace(city))
{
results = await PhoneNumber.LocationByCityPaginatedSearchAsync(cleanedQuery, city, page, _postgresql).ConfigureAwait(false);
results = await PhoneNumber.LocationByCityPaginatedSearchAsync(cleanedQuery, city, page, _postgresql);
}
else
{
results = await PhoneNumber.LocationPaginatedSearchAsync(cleanedQuery, page, _postgresql).ConfigureAwait(false);
results = await PhoneNumber.LocationPaginatedSearchAsync(cleanedQuery, page, _postgresql);
}
}
else
{
results = await PhoneNumber.RecommendedPaginatedSearchAsync(cleanedQuery, page, _postgresql).ConfigureAwait(false);
results = await PhoneNumber.RecommendedPaginatedSearchAsync(cleanedQuery, page, _postgresql);
}

var cart = Cart.GetFromSession(HttpContext.Session);
Cart cart = Cart.GetFromSession(HttpContext.Session);

// The query is a complete phone number and we have no results, perhaps they mean to port it?
if (cleanedQuery.Length == 10 && !cleanedQuery.Contains('*') && !results.Any())
Expand Down
6 changes: 5 additions & 1 deletion NumberSearch.Ops/Models/Cart.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

using AccelerateNetworks.Operations;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;

namespace NumberSearch.Ops.Models
{
Expand Down Expand Up @@ -445,7 +447,9 @@ public Dictionary<string, ProductOrder> ProductOrdersToDictionary()
{
var dict = new Dictionary<string, ProductOrder>();

foreach (var item in ProductOrders)
ReadOnlySpan<ProductOrder> span = CollectionsMarshal.AsSpan(ProductOrders);

foreach (var item in span)
{
var foreignId = string.Empty;

Expand Down
8 changes: 6 additions & 2 deletions NumberSearch.Tests/Ingest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ public FunctionalIngest(ITestOutputHelper output)
EmailTom = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailTom")) ? throw new Exception("EmailTom config key is blank.") : config.GetConnectionString("EmailTom").AsMemory(),
FusionPBXUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("FusionPBXUsername")) ? throw new Exception("FusionPBXUsername config key is blank.") : config.GetConnectionString("FusionPBXUsername").AsMemory(),
FusionPBXPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("FusionPBXPassword")) ? throw new Exception("FusionPBXPassword config key is blank.") : config.GetConnectionString("FusionPBXPassword").AsMemory(),
InvoiceNinjaToken = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailTom")) ? throw new Exception("InvoiceNinjaToken config key is blank.") : config.GetConnectionString("InvoiceNinjaToken").AsMemory(),
InvoiceNinjaToken = string.IsNullOrWhiteSpace(config.GetConnectionString("InvoiceNinjaToken")) ? throw new Exception("InvoiceNinjaToken config key is blank.") : config.GetConnectionString("InvoiceNinjaToken").AsMemory(),
MessagingUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("MessagingUsername")) ? throw new Exception("MessagingUsername config key is blank.") : config.GetConnectionString("MessagingUsername").AsMemory(),
MessagingPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("MessagingPassword")) ? throw new Exception("MessagingPassword config key is blank.") : config.GetConnectionString("MessagingPassword").AsMemory(),
MessagingURL = string.IsNullOrWhiteSpace(config.GetConnectionString("MessagingURL")) ? throw new Exception("MessagingURL config key is blank.") : config.GetConnectionString("MessagingURL").AsMemory()
};
ingestConfiguration = appConfig;
}
Expand Down Expand Up @@ -128,7 +131,8 @@ public FunctionalIngest(ITestOutputHelper output)
//[Fact]
//public async Task DailyBreifingEmailToDan()
//{
// var checkRun = await Orders.DailyBriefingEmailAsync(ingestConfiguration);
// var emptyChanges = Array.Empty<Owned.SMSRouteChange>();
// var checkRun = await Orders.DailyBriefingEmailAsync(emptyChanges, ingestConfiguration);
//}

//[Fact]
Expand Down

0 comments on commit 50c737f

Please sign in to comment.