mirror of
https://github.com/space-wizards/space-station-14.git
synced 2026-02-14 19:29:53 +01:00
Server names and admin log full-text search (#6327)
Co-authored-by: Julian Giebel <j.giebel@netrocks.info> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace Content.Server.Database
|
||||
{
|
||||
@@ -59,6 +61,10 @@ namespace Content.Server.Database
|
||||
"NOT inet '::ffff:0.0.0.0/96' >>= address");
|
||||
// ReSharper restore StringLiteralTypo
|
||||
|
||||
modelBuilder.Entity<AdminLog>()
|
||||
.HasIndex(l => l.Message)
|
||||
.IsTsVectorExpressionIndex("english");
|
||||
|
||||
foreach(var entity in modelBuilder.Model.GetEntityTypes())
|
||||
{
|
||||
foreach(var property in entity.GetProperties())
|
||||
@@ -68,5 +74,10 @@ namespace Content.Server.Database
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override IQueryable<AdminLog> SearchLogs(IQueryable<AdminLog> query, string searchText)
|
||||
{
|
||||
return query.Where(log => EF.Functions.ToTsVector("english", log.Message).Matches(searchText));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user