Compare commits

..

No commits in common. "0c0ed7226a330ae85fd80727e6ca1491b6f58158" and "cdb60e59ca3c873f58c1db7abfe80eae2199a73b" have entirely different histories.

9 changed files with 29 additions and 70 deletions

13
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
open-pull-requests-limit: 5
- package-ecosystem: npm
directory: /infra/cdk
schedule:
interval: weekly
open-pull-requests-limit: 5

View file

@ -1,6 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"enabledManagers": ["nuget", "npm", "github-actions"],
"enabledManagers": ["nuget", "npm"],
"minimumReleaseAge": "3 days",
"internalChecksFilter": "strict",
"packageRules": [

View file

@ -47,10 +47,10 @@ public class LocationControllerSitesTests
private static async Task SeedSitesAsync(ApplicationDbContext ctx)
{
ctx.Locations.AddRange(
new Locations { Id = 1, Name = "STL8", City = "St. Louis", State = "MO", AccountId = 100 },
new Locations { Id = 2, Name = "BK5", City = "Dallas", State = "TX", AccountId = 100 },
new Locations { Id = 3, Name = "IND9", City = "Indianapolis", State = "IN", AccountId = 100 },
new Locations { Id = 4, Name = "DFW8", City = "Dallas", State = "TX", AccountId = 100 });
new Locations { Id = 1, Name = "STL8", City = "St. Louis", State = "MO" },
new Locations { Id = 2, Name = "BK5", City = "Dallas", State = "TX" },
new Locations { Id = 3, Name = "IND9", City = "Indianapolis", State = "IN" },
new Locations { Id = 4, Name = "DFW8", City = "Dallas", State = "TX" });
await ctx.SaveChangesAsync();
}
@ -108,44 +108,4 @@ public class LocationControllerSitesTests
data.Should().HaveCount(2);
data.Select(s => s.Code).Should().BeEquivalentTo("BK5", "DFW8");
}
[Fact]
public async Task GetSites_OmitsLocationsWithoutAccountMapping()
{
await using var ctx = NewContext();
ctx.Locations.AddRange(
new Locations { Id = 1, Name = "STL8", City = "St. Louis", State = "MO", AccountId = 100 },
new Locations { Id = 2, Name = "UNMAPPED1", City = "Nowhere", State = "ZZ" });
await ctx.SaveChangesAsync();
var controller = NewController(ctx);
var result = await controller.GetSites();
var ok = result.Should().BeOfType<OkObjectResult>().Subject;
var data = ok.Value.Should().BeAssignableTo<IReadOnlyList<SiteOptionDTO>>().Subject;
data.Should().ContainSingle();
data[0].Code.Should().Be("STL8");
var searchResult = await controller.GetSites("unmapped1");
var searchOk = searchResult.Should().BeOfType<OkObjectResult>().Subject;
var searchData = searchOk.Value.Should().BeAssignableTo<IReadOnlyList<SiteOptionDTO>>().Subject;
searchData.Should().BeEmpty();
}
[Fact]
public async Task GetSites_ForwardsCancellationToken()
{
await using var ctx = NewContext();
await SeedSitesAsync(ctx);
var controller = NewController(ctx);
using var cancellation = new CancellationTokenSource();
await cancellation.CancelAsync();
var act = () => controller.GetSites(cancellationToken: cancellation.Token);
await act.Should().ThrowAsync<OperationCanceledException>();
}
}

View file

@ -27,11 +27,9 @@ namespace Api.SeaHavenIndustries.Controllers
}
[HttpGet("sites")]
public async Task<IActionResult> GetSites(
string? search = null,
CancellationToken cancellationToken = default)
public async Task<IActionResult> GetSites(string? search = null)
{
var data = await _locationService.GetSiteOptionsAsync(search, cancellationToken);
var data = await _locationService.GetSiteOptionsAsync(search);
return Ok(data);
}

View file

@ -74,13 +74,9 @@ namespace SeaHaven.DataServices.Implementation
return (items, totalCount);
}
public async Task<IReadOnlyList<SiteOptionRow>> GetSiteOptionsAsync(
string? search = null,
CancellationToken cancellationToken = default)
public async Task<IReadOnlyList<SiteOptionRow>> GetSiteOptionsAsync(string? search = null)
{
var query = _context.Locations
.AsNoTracking()
.Where(l => l.AccountId != null);
var query = _context.Locations.AsNoTracking();
if (!string.IsNullOrWhiteSpace(search))
{
@ -93,7 +89,7 @@ namespace SeaHaven.DataServices.Implementation
return await query
.OrderBy(l => l.Name)
.Select(l => new SiteOptionRow(l.Id, l.Name, l.City, l.State))
.ToListAsync(cancellationToken);
.ToListAsync();
}
public async Task<Locations> AddAsync(Locations location)

View file

@ -17,9 +17,7 @@ namespace SeaHaven.DataServices.Interfaces
// For addressbook endpoint - returns simplified DTO
Task<(IEnumerable<object> Items, int TotalCount)> GetAddressbookPagedAsync(int page, int pageSize, string? search = null);
Task<IReadOnlyList<SiteOptionRow>> GetSiteOptionsAsync(
string? search = null,
CancellationToken cancellationToken = default);
Task<IReadOnlyList<SiteOptionRow>> GetSiteOptionsAsync(string? search = null);
/// <summary>
/// Exists is false when the row is missing. AccountId is null when the site has no account.

View file

@ -70,11 +70,9 @@ namespace SeaHaven.Services.Implementation
};
}
public async Task<IReadOnlyList<SiteOptionDTO>> GetSiteOptionsAsync(
string? search = null,
CancellationToken cancellationToken = default)
public async Task<IReadOnlyList<SiteOptionDTO>> GetSiteOptionsAsync(string? search = null)
{
var rows = await _locationDataService.GetSiteOptionsAsync(search, cancellationToken);
var rows = await _locationDataService.GetSiteOptionsAsync(search);
return rows
.Select(r => new SiteOptionDTO
{

View file

@ -10,9 +10,7 @@ namespace SeaHaven.Services.Interfaces
Task<IEnumerable<LocationDTO>> GetAllLocationsAsync();
Task<IEnumerable<LocationDTO>> GetLocationsByAccountIdAsync(int accountId);
Task<PagedResult<LocationDTO>> GetLocationsPagedAsync(int page, int pageSize, string? search = null);
Task<IReadOnlyList<SiteOptionDTO>> GetSiteOptionsAsync(
string? search = null,
CancellationToken cancellationToken = default);
Task<IReadOnlyList<SiteOptionDTO>> GetSiteOptionsAsync(string? search = null);
Task<LocationDTO> CreateLocationAsync(CreateLocationDTO dto, string userId);
Task<LocationDTO> UpdateLocationAsync(int id, UpdateLocationDTO dto, string userId);
Task DeleteLocationAsync(int id, string userId);

View file

@ -816,10 +816,8 @@ public class WorkOrderAccountScopeTests
=> _inner.GetPagedAsync(page, pageSize, search);
public Task<(IEnumerable<object> Items, int TotalCount)> GetAddressbookPagedAsync(int page, int pageSize, string? search = null)
=> _inner.GetAddressbookPagedAsync(page, pageSize, search);
public Task<IReadOnlyList<SiteOptionRow>> GetSiteOptionsAsync(
string? search = null,
CancellationToken cancellationToken = default)
=> _inner.GetSiteOptionsAsync(search, cancellationToken);
public Task<IReadOnlyList<SiteOptionRow>> GetSiteOptionsAsync(string? search = null)
=> _inner.GetSiteOptionsAsync(search);
public Task<(bool Exists, int? AccountId)> GetAccountScopeAsync(
int locationId,