update sunday

This commit is contained in:
Chris Chen
2026-06-23 20:20:12 -07:00
parent a2ecc895de
commit b0deb62c82
5 changed files with 15 additions and 8 deletions
@@ -16,7 +16,7 @@ public class MealAttendanceController : ControllerBase
[HttpGet("today")] [HttpGet("today")]
[AllowAnonymous] [AllowAnonymous]
public async Task<IActionResult> GetToday() public async Task<IActionResult> GetToday()
=> Ok(await _svc.GetOrCreateAsync(_svc.Today)); => Ok(await _svc.GetOrCreateAsync(_svc.ServiceDay));
/// <summary>Daily counts within a date range, for the back-office dashboard chart.</summary> /// <summary>Daily counts within a date range, for the back-office dashboard chart.</summary>
[HttpGet] [HttpGet]
+3 -3
View File
@@ -18,7 +18,7 @@ public class AttendanceHub : Hub
// Push the current counts to a client the moment it connects. // Push the current counts to a client the moment it connects.
public override async Task OnConnectedAsync() public override async Task OnConnectedAsync()
{ {
var counts = await _svc.GetOrCreateAsync(_svc.Today); var counts = await _svc.GetOrCreateAsync(_svc.ServiceDay);
await Clients.Caller.SendAsync("ReceiveCounts", counts); await Clients.Caller.SendAsync("ReceiveCounts", counts);
await base.OnConnectedAsync(); await base.OnConnectedAsync();
} }
@@ -26,14 +26,14 @@ public class AttendanceHub : Hub
// Apply a batched delta for one age group, then broadcast the new totals to everyone. // Apply a batched delta for one age group, then broadcast the new totals to everyone.
public async Task Increment(string category, int delta) public async Task Increment(string category, int delta)
{ {
var counts = await _svc.IncrementAsync(_svc.Today, category, delta); var counts = await _svc.IncrementAsync(_svc.ServiceDay, category, delta);
await Clients.All.SendAsync("ReceiveCounts", counts); await Clients.All.SendAsync("ReceiveCounts", counts);
} }
// Overwrite one age group with an absolute value, then broadcast the new totals to everyone. // Overwrite one age group with an absolute value, then broadcast the new totals to everyone.
public async Task SetCount(string category, int value) public async Task SetCount(string category, int value)
{ {
var counts = await _svc.SetAsync(_svc.Today, category, value); var counts = await _svc.SetAsync(_svc.ServiceDay, category, value);
await Clients.All.SendAsync("ReceiveCounts", counts); await Clients.All.SendAsync("ReceiveCounts", counts);
} }
} }
@@ -5,7 +5,7 @@ namespace ROLAC.API.Services;
public interface IMealAttendanceService public interface IMealAttendanceService
{ {
/// <summary>Today's date in the server's local time zone (the church's "current Sunday").</summary> /// <summary>Today's date in the server's local time zone (the church's "current Sunday").</summary>
DateOnly Today { get; } DateOnly ServiceDay { get; }
/// <summary>Returns the counts for <paramref name="date"/>, creating a zeroed row if none exists.</summary> /// <summary>Returns the counts for <paramref name="date"/>, creating a zeroed row if none exists.</summary>
Task<AttendanceCountsDto> GetOrCreateAsync(DateOnly date); Task<AttendanceCountsDto> GetOrCreateAsync(DateOnly date);
@@ -12,7 +12,14 @@ public class MealAttendanceService : IMealAttendanceService
public MealAttendanceService(AppDbContext db) => _db = db; public MealAttendanceService(AppDbContext db) => _db = db;
// Server local time is assumed to match the church's local day. // Server local time is assumed to match the church's local day.
public DateOnly Today => DateOnly.FromDateTime(DateTime.Now); public DateOnly ServiceDay
{
get
{
var today = DateOnly.FromDateTime(DateTime.Now);
return today.AddDays(-(int)today.DayOfWeek);
}
}
public async Task<AttendanceCountsDto> GetOrCreateAsync(DateOnly date) public async Task<AttendanceCountsDto> GetOrCreateAsync(DateOnly date)
{ {
+2 -2
View File
@@ -1,5 +1,5 @@
{ {
"name": "RBJ.Identity.App", "name": "ROLAC.App",
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
@@ -92,4 +92,4 @@
"tailwindcss": "^4.3.0", "tailwindcss": "^4.3.0",
"typescript": "~5.8.2" "typescript": "~5.8.2"
} }
} }