| 1 | using AgentForge.Abstractions; |
| 2 | |
| 3 | namespace AgentForge.Plugin.Grouping.Core; |
| 4 | |
| 5 | public static class ForgeGroupingDateBuckets |
| 6 | { |
| 7 | public static string Bucket(DateTimeOffset? timestamp, DateTimeOffset utcNow) |
| 8 | { |
| 9 | if (timestamp is null) |
| 10 | return "unknown"; |
| 11 | |
| 12 | var age = utcNow - timestamp.Value; |
| 13 | if (age <= TimeSpan.FromDays(1)) |
| 14 | return "today"; |
| 15 | if (age <= TimeSpan.FromDays(7)) |
| 16 | return "last_7_days"; |
| 17 | if (age <= TimeSpan.FromDays(30)) |
| 18 | return "last_30_days"; |
| 19 | return "older"; |
| 20 | } |
| 21 | |
| 22 | public static IReadOnlyList<ForgeGroupingSection> Sections() => |
| 23 | [ |
| 24 | new("today", "Today"), |
| 25 | new("last_7_days", "Last 7 days"), |
| 26 | new("last_30_days", "Last 30 days"), |
| 27 | new("older", "Older"), |
| 28 | new("unknown", "Unknown"), |
| 29 | ]; |
| 30 | } |
| 31 | |
View only · write via MCP/CIDE