mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-03 16:24:27 -05:00 
			
		
		
		
	.curtrs may? run a little faster. Uses async, clarified GamblingConfig transactionLifetime field
This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
			
		||||
#nullable disable
 | 
			
		||||
using LinqToDB.EntityFrameworkCore;
 | 
			
		||||
using Microsoft.EntityFrameworkCore;
 | 
			
		||||
using NadekoBot.Services.Database.Models;
 | 
			
		||||
 | 
			
		||||
@@ -6,12 +7,14 @@ namespace NadekoBot.Db;
 | 
			
		||||
 | 
			
		||||
public static class CurrencyTransactionExtensions
 | 
			
		||||
{
 | 
			
		||||
    public static List<CurrencyTransaction> GetPageFor(this DbSet<CurrencyTransaction> set, ulong userId, int page)
 | 
			
		||||
        => set.AsQueryable()
 | 
			
		||||
              .AsNoTracking()
 | 
			
		||||
              .Where(x => x.UserId == userId)
 | 
			
		||||
              .OrderByDescending(x => x.DateAdded)
 | 
			
		||||
              .Skip(15 * page)
 | 
			
		||||
              .Take(15)
 | 
			
		||||
              .ToList();
 | 
			
		||||
    public static Task<List<CurrencyTransaction>> GetPageFor(
 | 
			
		||||
        this DbSet<CurrencyTransaction> set,
 | 
			
		||||
        ulong userId,
 | 
			
		||||
        int page)
 | 
			
		||||
        => set.ToLinqToDBTable()
 | 
			
		||||
            .Where(x => x.UserId == userId)
 | 
			
		||||
            .OrderByDescending(x => x.DateAdded)
 | 
			
		||||
            .Skip(15 * page)
 | 
			
		||||
            .Take(15)
 | 
			
		||||
            .ToListAsyncLinqToDB();
 | 
			
		||||
}
 | 
			
		||||
@@ -249,7 +249,7 @@ public partial class Gambling : GamblingModule<GamblingService>
 | 
			
		||||
        List<CurrencyTransaction> trs;
 | 
			
		||||
        await using (var uow = _db.GetDbContext())
 | 
			
		||||
        {
 | 
			
		||||
            trs = uow.CurrencyTransactions.GetPageFor(userId, page);
 | 
			
		||||
            trs = await uow.CurrencyTransactions.GetPageFor(userId, page);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var embed = _eb.Create()
 | 
			
		||||
 
 | 
			
		||||
@@ -78,7 +78,7 @@ public class CurrencyConfig
 | 
			
		||||
    [Comment(@"What is the name of the currency")]
 | 
			
		||||
    public string Name { get; set; } = "Nadeko Flower";
 | 
			
		||||
 | 
			
		||||
    [Comment(@"For how long will the transactions be kept in the database (curtrs)
 | 
			
		||||
    [Comment(@"For how long (in days) will the transactions be kept in the database (curtrs)
 | 
			
		||||
Set 0 to disable cleanup (keep transactions forever)")]
 | 
			
		||||
    public int TransactionsLifetime { get; set; } = 0;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user