From e1a9117b4a3b5012432c973c3d1b893cdb103cd5 Mon Sep 17 00:00:00 2001 From: Meleki Date: Sat, 14 Mar 2026 17:30:59 +0100 Subject: [PATCH] fix: adopted_api_key_id konsistent als string key_id statt numerischer rowid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CreateApiKey() gibt jetzt string key_id zurück statt long rowid - SetScannedKeyAdopted() erwartet string statt long - DeleteApiKey() direkter Vergleich statt Subquery - DB-Explorer: PageSize Default auf 1000 erhöht --- Endpoints/DatabaseExplorerEndpoint.cs | 4 ++-- Services/DatabaseService.Integrations.cs | 8 ++++---- wwwroot/js/pages/db-explorer-page.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Endpoints/DatabaseExplorerEndpoint.cs b/Endpoints/DatabaseExplorerEndpoint.cs index d707c12..c033d4c 100644 --- a/Endpoints/DatabaseExplorerEndpoint.cs +++ b/Endpoints/DatabaseExplorerEndpoint.cs @@ -66,10 +66,10 @@ public static class DatabaseExplorerEndpoint // Pagination var page = 1; - var pageSize = 100; + var pageSize = 1000; if (ctx.Request.Query.TryGetValue("page", out var pageStr) && int.TryParse(pageStr, out var p) && p > 0) page = p; - if (ctx.Request.Query.TryGetValue("pageSize", out var psStr) && int.TryParse(psStr, out var ps) && ps > 0 && ps <= 500) + if (ctx.Request.Query.TryGetValue("pageSize", out var psStr) && int.TryParse(psStr, out var ps) && ps > 0 && ps <= 10000) pageSize = ps; var offset = (page - 1) * pageSize; diff --git a/Services/DatabaseService.Integrations.cs b/Services/DatabaseService.Integrations.cs index 671ebd2..9f54dce 100644 --- a/Services/DatabaseService.Integrations.cs +++ b/Services/DatabaseService.Integrations.cs @@ -367,14 +367,14 @@ public partial class DatabaseService } - public async Task CreateApiKey(ApiKeyRecord record) + public async Task CreateApiKey(ApiKeyRecord record) { using var conn = CreateConnection(); await conn.ExecuteAsync(@" INSERT INTO api_keys (key_id, provider, name, api_key, is_public, status, plan, usage_7d, usage_5h, checked_at, source_url, created_at, updated_at) VALUES (@KeyId, @Provider, @Name, @ApiKey, @IsPublic, @Status, @Plan, @Usage7d, @Usage5h, @CheckedAt, @SourceUrl, @CreatedAt, @UpdatedAt)", record); - return await conn.ExecuteScalarAsync("SELECT last_insert_rowid()"); + return record.KeyId; } public async Task UpdateApiKey(string keyId, string name, string apiKey = null) @@ -425,7 +425,7 @@ public partial class DatabaseService using var conn = CreateConnection(); // Scanned-Keys die auf diesen API-Key verweisen zurücksetzen await conn.ExecuteAsync( - "UPDATE scanned_keys SET adopted_api_key_id = NULL WHERE adopted_api_key_id = (SELECT id FROM api_keys WHERE key_id = @keyId)", + "UPDATE scanned_keys SET adopted_api_key_id = NULL WHERE adopted_api_key_id = @keyId", new { keyId }); // User die diesen Key ausgewählt haben zurücksetzen await conn.ExecuteAsync( @@ -505,7 +505,7 @@ public partial class DatabaseService new { scannedKeyId }); } - public async Task SetScannedKeyAdopted(string scannedKeyId, long apiKeyId) + public async Task SetScannedKeyAdopted(string scannedKeyId, string apiKeyId) { using var conn = CreateConnection(); await conn.ExecuteAsync( diff --git a/wwwroot/js/pages/db-explorer-page.js b/wwwroot/js/pages/db-explorer-page.js index b334fca..ce868a6 100644 --- a/wwwroot/js/pages/db-explorer-page.js +++ b/wwwroot/js/pages/db-explorer-page.js @@ -75,7 +75,7 @@ registerPage('db-explorer', { }); try { - var resp = await fetch('/api/admin/db/tables/' + encodeURIComponent(name) + '?page=' + page + '&pageSize=100'); + var resp = await fetch('/api/admin/db/tables/' + encodeURIComponent(name) + '?page=' + page + '&pageSize=1000'); var data = await resp.json(); contentEl.innerHTML = '';