mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 18:28:27 -04:00
- Database namespace is now NadekoBot.Db
- Db related code is now in src/NadekoBot/Db - Finished major part of the db refactor, but many optimizations are left to be made
This commit is contained in:
22
src/NadekoBot/Db/Extensions/ReminderExtensions.cs
Normal file
22
src/NadekoBot/Db/Extensions/ReminderExtensions.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using NadekoBot.Core.Services.Database.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace NadekoBot.Db
|
||||
{
|
||||
public static class ReminderExtensions
|
||||
{
|
||||
public static IEnumerable<Reminder> GetIncludedReminders(this DbSet<Reminder> reminders, IEnumerable<ulong> guildIds)
|
||||
=> reminders.AsQueryable()
|
||||
.Where(x => guildIds.Contains(x.ServerId) || x.ServerId == 0)
|
||||
.ToList();
|
||||
|
||||
public static IEnumerable<Reminder> RemindersFor(this DbSet<Reminder> reminders, ulong userId, int page)
|
||||
=> reminders.AsQueryable()
|
||||
.Where(x => x.UserId == userId)
|
||||
.OrderBy(x => x.DateAdded)
|
||||
.Skip(page * 10)
|
||||
.Take(10);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user