feat(health): oldest-parked-message age on the site health report (parked-retention aging signal)
This commit is contained in:
@@ -663,6 +663,26 @@ public class StoreAndForwardStorage
|
||||
return Convert.ToInt32(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <c>created_at</c> of the oldest parked message, or <c>null</c> when
|
||||
/// no rows are parked. Backs the parked-retention aging signal on the site health
|
||||
/// report: parked rows persist until an operator acts, so their <i>age</i> — not
|
||||
/// just their count — is what tells an operator a forgotten site's backlog is
|
||||
/// growing stale.
|
||||
/// </summary>
|
||||
/// <returns>A task that resolves to the oldest parked row's creation time, or <c>null</c> if none are parked.</returns>
|
||||
public async Task<DateTimeOffset?> GetOldestParkedCreatedAtAsync()
|
||||
{
|
||||
await using var conn = await OpenConnectionAsync();
|
||||
await using var cmd = conn.CreateCommand();
|
||||
cmd.CommandText = "SELECT MIN(created_at) FROM sf_messages WHERE status = @parked";
|
||||
cmd.Parameters.AddWithValue("@parked", (int)StoreAndForwardMessageStatus.Parked);
|
||||
var result = await cmd.ExecuteScalarAsync();
|
||||
return result is null or DBNull
|
||||
? null
|
||||
: DateTimeOffset.Parse((string)result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets total message count by status.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user