Show the strategy of each catch in the dashboard
Add a Strategie column to the catch list (searchable, filterable) and a Strategien tab to the Top 10 card. The MCP top tool accepts strategies. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7d3e6f8842
commit
b7027e2a72
15 files changed
+83
-24
No files matched your search
@@ -10,6 +10,7 @@ public sealed record DashboardData(
|
||||
TimeSpan TotalHoldTime,
|
||||
IReadOnlyList<TopEntry> TopIps,
|
||||
IReadOnlyList<TopEntry> TopTargets,
|
||||
IReadOnlyList<TopEntry> TopStrategies,
|
||||
IReadOnlyList<TopEntry> TopCountries,
|
||||
IReadOnlyList<TopEntry> TopProviders,
|
||||
IReadOnlyDictionary<string, int> CatchesByCountry);
|
||||
|
||||
@@ -42,6 +42,7 @@ public sealed class DashboardQueries(IDbContextFactory<FlypaperDbContext> dbCont
|
||||
TimeSpan.FromMilliseconds(await catches.SumAsync(e => e.DurationMs, ct)),
|
||||
await TopAsync(catches.GroupBy(e => e.RemoteIp), ct),
|
||||
await TopAsync(catches.Where(e => e.Target != null).GroupBy(e => e.Target!), ct),
|
||||
await TopAsync(catches.GroupBy(e => e.Strategy), ct),
|
||||
countries
|
||||
.Take(TopCount)
|
||||
.Select(x => new TopEntry(x.Key, x.Count, TimeSpan.FromMilliseconds(x.DurationMs), x.Name))
|
||||
@@ -104,6 +105,11 @@ public sealed class DashboardQueries(IDbContextFactory<FlypaperDbContext> dbCont
|
||||
events = events.Where(e => e.Target == target);
|
||||
}
|
||||
|
||||
if (filter.Strategy is { } strategy)
|
||||
{
|
||||
events = events.Where(e => e.Strategy == strategy);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(filter.Search))
|
||||
{
|
||||
var pattern = $"%{filter.Search.Trim().Replace("\\", "\\\\").Replace("%", "\\%").Replace("_", "\\_")}%";
|
||||
@@ -111,6 +117,7 @@ public sealed class DashboardQueries(IDbContextFactory<FlypaperDbContext> dbCont
|
||||
EF.Functions.Like(e.RemoteIp, pattern, "\\")
|
||||
|| EF.Functions.Like(e.Provider!, pattern, "\\")
|
||||
|| EF.Functions.Like(e.Target!, pattern, "\\")
|
||||
|| EF.Functions.Like(e.Strategy, pattern, "\\")
|
||||
|| EF.Functions.Like(e.ClientInfo!, pattern, "\\"));
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ public sealed record RecentFilter(
|
||||
long? Asn = null,
|
||||
string? Ip = null,
|
||||
string? Target = null,
|
||||
string? Strategy = null,
|
||||
string? Search = null,
|
||||
int Limit = RecentFilter.DefaultLimit)
|
||||
{
|
||||
|
||||
@@ -93,6 +93,8 @@ public sealed class CatchQueries(IDbContextFactory<FlypaperDbContext> dbContextF
|
||||
.Select(g => new TopRow { Key = "AS" + g.Key.ToString(), Label = g.Max(e => e.Provider), Count = g.Count(), DurationMs = g.Sum(e => e.DurationMs) }),
|
||||
TopDimension.Targets => catches.Where(e => e.Target != null).GroupBy(e => e.Target!)
|
||||
.Select(g => new TopRow { Key = g.Key, Count = g.Count(), DurationMs = g.Sum(e => e.DurationMs) }),
|
||||
TopDimension.Strategies => catches.GroupBy(e => e.Strategy)
|
||||
.Select(g => new TopRow { Key = g.Key, Count = g.Count(), DurationMs = g.Sum(e => e.DurationMs) }),
|
||||
TopDimension.UserAgents => catches.Where(e => e.ClientInfo != null).GroupBy(e => e.ClientInfo!)
|
||||
.Select(g => new TopRow { Key = g.Key, Count = g.Count(), DurationMs = g.Sum(e => e.DurationMs) }),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(dimension))
|
||||
|
||||
@@ -42,6 +42,7 @@ public enum TopDimension
|
||||
Countries,
|
||||
Providers,
|
||||
Targets,
|
||||
Strategies,
|
||||
UserAgents
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user