IW4M-Admin/Application/Migration/DatabaseHousekeeping.cs
RaidMax a574fb0d4b update index for ratings/prune old entries
small stat tweaks to add players on first kill/damage event
(instead of on connect which causes issues with slow writes)
2020-11-14 18:24:51 -06:00

20 lines
599 B
C#

using System;
using System.Linq;
using IW4MAdmin.Plugins.Stats.Models;
using SharedLibraryCore.Database;
namespace IW4MAdmin.Application.Migration
{
public static class DatabaseHousekeeping
{
private static DateTime _cutoffDate = DateTime.UtcNow.AddMonths(-6);
public static void RemoveOldRatings(DatabaseContext context)
{
var dbSet = context.Set<EFRating>();
var itemsToDelete = dbSet.Where(rating => rating.When <= _cutoffDate);
dbSet.RemoveRange(itemsToDelete);
context.SaveChanges();
}
}
}