fix: adopted_api_key_id konsistent als string key_id statt numerischer rowid
- 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
This commit is contained in:
1 parent
ce50633e33
commit
e1a9117b4a
3 files changed
+7
-7
No files matched your search
@@ -66,10 +66,10 @@ public static class DatabaseExplorerEndpoint
|
|||||||
|
|
||||||
// Pagination
|
// Pagination
|
||||||
var page = 1;
|
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)
|
if (ctx.Request.Query.TryGetValue("page", out var pageStr) && int.TryParse(pageStr, out var p) && p > 0)
|
||||||
page = p;
|
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;
|
pageSize = ps;
|
||||||
|
|
||||||
var offset = (page - 1) * pageSize;
|
var offset = (page - 1) * pageSize;
|
||||||
|
|||||||
@@ -367,14 +367,14 @@ public partial class DatabaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<long> CreateApiKey(ApiKeyRecord record)
|
public async Task<string> CreateApiKey(ApiKeyRecord record)
|
||||||
{
|
{
|
||||||
using var conn = CreateConnection();
|
using var conn = CreateConnection();
|
||||||
await conn.ExecuteAsync(@"
|
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)
|
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)",
|
VALUES (@KeyId, @Provider, @Name, @ApiKey, @IsPublic, @Status, @Plan, @Usage7d, @Usage5h, @CheckedAt, @SourceUrl, @CreatedAt, @UpdatedAt)",
|
||||||
record);
|
record);
|
||||||
return await conn.ExecuteScalarAsync<long>("SELECT last_insert_rowid()");
|
return record.KeyId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateApiKey(string keyId, string name, string apiKey = null)
|
public async Task UpdateApiKey(string keyId, string name, string apiKey = null)
|
||||||
@@ -425,7 +425,7 @@ public partial class DatabaseService
|
|||||||
using var conn = CreateConnection();
|
using var conn = CreateConnection();
|
||||||
// Scanned-Keys die auf diesen API-Key verweisen zurücksetzen
|
// Scanned-Keys die auf diesen API-Key verweisen zurücksetzen
|
||||||
await conn.ExecuteAsync(
|
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 });
|
new { keyId });
|
||||||
// User die diesen Key ausgewählt haben zurücksetzen
|
// User die diesen Key ausgewählt haben zurücksetzen
|
||||||
await conn.ExecuteAsync(
|
await conn.ExecuteAsync(
|
||||||
@@ -505,7 +505,7 @@ public partial class DatabaseService
|
|||||||
new { scannedKeyId });
|
new { scannedKeyId });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SetScannedKeyAdopted(string scannedKeyId, long apiKeyId)
|
public async Task SetScannedKeyAdopted(string scannedKeyId, string apiKeyId)
|
||||||
{
|
{
|
||||||
using var conn = CreateConnection();
|
using var conn = CreateConnection();
|
||||||
await conn.ExecuteAsync(
|
await conn.ExecuteAsync(
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ registerPage('db-explorer', {
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
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();
|
var data = await resp.json();
|
||||||
|
|
||||||
contentEl.innerHTML = '';
|
contentEl.innerHTML = '';
|
||||||
|
|||||||
Reference in new issue
Block a user