From 4534d4dbf5f5071fa71c5dec4444bf4b2bbd040c Mon Sep 17 00:00:00 2001 From: Rory& Date: Sun, 14 Dec 2025 23:18:35 +0100 Subject: admin api packaging --- extra/admin-api/ConfigTest/Worker.cs | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 extra/admin-api/ConfigTest/Worker.cs (limited to 'extra/admin-api/ConfigTest/Worker.cs') diff --git a/extra/admin-api/ConfigTest/Worker.cs b/extra/admin-api/ConfigTest/Worker.cs new file mode 100644 index 000000000..dd3ef7791 --- /dev/null +++ b/extra/admin-api/ConfigTest/Worker.cs @@ -0,0 +1,43 @@ +using System.Text.Json.Nodes; +using Spacebar.ConfigModel.Extensions; +using Spacebar.Db.Contexts; + +namespace ConfigTest; + +public class Worker(ILogger logger, SpacebarDbContext db) : BackgroundService +{ + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + var config = db.Configs + .OrderBy(x => x.Key) + .ToDictionary(x => x.Key, x => x.Value); + foreach (var (key, value) in config) + { + Console.WriteLine("Config Key: {0}, Value: {1}", key, value ?? "[NULL]"); + } + + var readConfig = config.ToNestedJsonObject(); + Console.WriteLine(readConfig); + var mapped = readConfig.ToFlatKv(); + foreach (var (key, value) in mapped) + { + Console.WriteLine("Mapped Key: {0}, Value: {1}", key, value ?? "[NULL]"); + } + + // check that they're equal + foreach (var (key, value) in config) + { + if (!mapped.ContainsKey(key)) + { + Console.WriteLine("Missing Key in Mapped: {0}", key); + continue; + } + + if (mapped[key] != value) + { + Console.WriteLine("Value Mismatch for Key: {0}, Original: {1}, Mapped: {2}", key, value ?? "[NULL]", mapped[key] ?? "[NULL]"); + } + } + Environment.Exit(0); + } +} \ No newline at end of file -- cgit 1.5.1