This commit is contained in:
2026-01-08 15:18:34 +01:00
parent d385119ca2
commit 33a0b77bf1
111 changed files with 85489 additions and 24 deletions

View File

@@ -0,0 +1,30 @@
using LogCentral.Server.Data;
using LogCentral.Server.Models;
using Microsoft.EntityFrameworkCore;
namespace LogCentral.Server.Services;
public interface ISearchService
{
Task<List<LogEntry>> SearchAsync(string query, int limit = 100);
}
public class SearchService : ISearchService
{
private readonly LogCentralDbContext _context;
public SearchService(LogCentralDbContext context)
{
_context = context;
}
public async Task<List<LogEntry>> SearchAsync(string query, int limit = 100)
{
return await _context.LogEntries
.Where(l => EF.Functions.Like(l.Message, $"%{query}%") ||
EF.Functions.Like(l.Exception ?? "", $"%{query}%"))
.OrderByDescending(l => l.Timestamp)
.Take(limit)
.ToListAsync();
}
}