sqlinsight-pro/src/SQLInsight.Community/Services/RuleCatalog.cs
Claude be35e50335
Some checks are pending
CI / Integration (mcr.microsoft.com/mssql/server:2025-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2019-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2022-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2017-latest) (push) Blocked by required conditions
CI / Build og unit tests (push) Successful in 1m1s
deploy hub / deploy (push) Successful in 19s
CI / MSI-installer (push) Successful in 36s
Community-websted og Discourse-forum
- src/SQLInsight.Community: offentligt websted med forside, funktioner, download
  af signerede udgivelser (med SHA-256), dokumentation fra docs/, SQL Server-
  versioner fra den nyeste signerede regelpakke, regler og supportaftaler.
  Viser de seneste forumemner. Streng CSP, ingen login, ingen database.
- deploy/forum: Discourse-opsætning (app.yml til discourse_docker, dansk
  sprog og søgning), install.sh og configure.py, der idempotent opsætter
  kategorier, løste svar, velkomstemne og indstillinger via API'et.
- deploy/community: Dockerfile og docker compose med Caddy til TLS.
- Webbrugerfladen linker til forum, dokumentation og support på webstedet
  (SQLInsight:Web:ForumUrl og CommunityUrl).
- Udgivelsesfiler hedder sqlinsight-<version>-<platform>.<ext>.
- Tests: sider, 404, signerede og manipulerede feeds, forum (også nede),
  dokumentationslinks og regler.
- docs/community.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E3EExwndy8Z22EK2Qpt6BK
2026-09-29 13:45:06 +00:00

46 lines
1.8 KiB
C#

using SQLInsight.Core.CustomRules;
using SQLInsight.Rules;
using SQLInsight.Rules.Engine;
namespace SQLInsight.Community.Services;
public sealed record RuleEntry(string Id, string Title, string Area, string? Author, bool Community);
/// <summary>Every rule the product ships: the built-in ones and the community rules in the rule pack.</summary>
public static class RuleCatalog
{
private static readonly Dictionary<string, string> Areas = new(StringComparer.Ordinal)
{
["VER"] = "Version og opdateringer",
["CFG"] = "Konfiguration",
["DB"] = "Databaser, backup og integritet",
["WAIT"] = "Ventetider",
["IO"] = "I/O",
["CPU"] = "CPU og hukommelse",
["MEM"] = "CPU og hukommelse",
["ANOM"] = "Afvigelser fra det normale",
["QS"] = "Query Store og planer",
["PLAN"] = "Query Store og planer",
["IDX"] = "Indexes og statistik",
["STAT"] = "Indexes og statistik",
["AG"] = "Always On og SQL Agent",
["JOB"] = "Always On og SQL Agent",
["BLK"] = "Blocking og deadlocks",
["DLK"] = "Blocking og deadlocks",
["SEC"] = "Sikkerhed",
};
public static IReadOnlyList<RuleEntry> All(IReadOnlyList<CustomRuleDefinition> community)
{
ArgumentNullException.ThrowIfNull(community);
IEnumerable<RuleEntry> builtIn = BuiltInRules.Create().Select(r => new RuleEntry(r.Id, r.Title, Area(r.Id), null, false));
return builtIn.Concat(community.Select(r => new RuleEntry(r.Id, r.Title, Area(r.Id), r.Author, true))).ToList();
}
public static string Area(string id)
{
ArgumentNullException.ThrowIfNull(id);
var parts = id.Split('-');
return parts.Length >= 2 && Areas.TryGetValue(parts[1], out var area) ? area : "Andet";
}
}