Files
Nexus.Reader/tests/NexusReader.Application.Tests/Queries/CheckDatabaseTest.cs
T
mjasin 8856fb1614 feat(creator): Refactor Creator flow, implement book creation pipeline & versioning, and setup Docker staging
- Relocate dashboard routing to /creator and editor workspace to /creator/edit/{BookId}
- Implement CreateBookCommand and handler with transactional default chapter seeding
- Implement PublishBookVersionCommand and GetCreatorDashboardDataQuery
- Build CreatorDashboard modal and UI components with customized dark input styles
- Add run-stage.sh script to automate staging environment setup, database migrations, and health checks
- Update developer workflow rules in GEMINI.md
2026-06-14 10:58:37 +02:00

59 lines
2.3 KiB
C#

using System;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using NexusReader.Data.Persistence;
using Xunit;
namespace NexusReader.Application.Tests.Queries;
public class CheckDatabaseTest
{
[Fact(Skip = "Requires live Postgres database in Docker")]
public async Task PrintDatabaseStats()
{
var configJson = await File.ReadAllTextAsync("../../../../../src/NexusReader.Web/appsettings.json");
var doc = JsonDocument.Parse(configJson);
var pgConn = doc.RootElement.GetProperty("ConnectionStrings").GetProperty("PostgresConnection").GetString();
Console.WriteLine($"Postgres Connection: {pgConn}");
var optionsBuilder = new DbContextOptionsBuilder<AppDbContext>();
optionsBuilder.UseNpgsql(pgConn);
using var context = new AppDbContext(optionsBuilder.Options);
var usersCount = await context.Users.CountAsync();
var ebooksCount = await context.Ebooks.CountAsync();
var unitsCount = await context.KnowledgeUnits.CountAsync();
var cacheCount = await context.SemanticKnowledgeCache.CountAsync();
Console.WriteLine($"=== DATABASE STATS ===");
Console.WriteLine($"Users: {usersCount}");
Console.WriteLine($"Ebooks: {ebooksCount}");
Console.WriteLine($"KnowledgeUnits: {unitsCount}");
Console.WriteLine($"SemanticKnowledgeCache: {cacheCount}");
var users = await context.Users.ToListAsync();
foreach (var u in users)
{
Console.WriteLine($"User: {u.Email}, TenantId: '{u.TenantId}'");
}
var ebooks = await context.Ebooks.ToListAsync();
foreach (var eb in ebooks)
{
Console.WriteLine($"Ebook Id: {eb.Id}, Title: '{eb.Title}', FilePath: '{eb.FilePath}', Ready: {eb.IsReadyForReading}");
}
var cache = await context.SemanticKnowledgeCache.ToListAsync();
foreach (var c in cache)
{
Console.WriteLine($"Cache Hash: {c.ContentHash}, TenantId: '{c.TenantId}', PromptVersion: {c.PromptVersion}, JsonData Preview: {c.JsonData.Substring(0, Math.Min(c.JsonData.Length, 150))}");
}
Assert.True(true);
}
}