feat: exorcise entity framework core from most responders

This commit is contained in:
sam 2024-10-27 23:02:42 +01:00
parent 33b78a7ac5
commit 5891f28f7c
Signed by: sam
GPG key ID: 5F3C3C1B3166639D
32 changed files with 743 additions and 145 deletions

View file

@ -13,7 +13,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
using Catalogger.Backend.Database;
using Catalogger.Backend.Database.Dapper.Repositories;
using Catalogger.Backend.Database.Queries;
namespace Catalogger.Backend.Services;
@ -34,7 +34,8 @@ public class BackgroundTasksService(ILogger logger, IServiceProvider services) :
_logger.Information("Running once per minute periodic tasks");
await using var scope = services.CreateAsyncScope();
var messageRepository = scope.ServiceProvider.GetRequiredService<MessageRepository>();
await using var messageRepository =
scope.ServiceProvider.GetRequiredService<DapperMessageRepository>();
var (msgCount, ignoredCount) = await messageRepository.DeleteExpiredMessagesAsync();
if (msgCount != 0 || ignoredCount != 0)
@ -43,7 +44,7 @@ public class BackgroundTasksService(ILogger logger, IServiceProvider services) :
"Deleted {Count} messages and {IgnoredCount} ignored message IDs older than {MaxDays} days old",
msgCount,
ignoredCount,
MessageRepository.MaxMessageAgeDays
DapperMessageRepository.MaxMessageAgeDays
);
}
}