Spaces:
Sleeping
Sleeping
SaluAi / src /Infrastructure /TelegramSaaS.Infrastructure /Persistence /Repositories /GenerationJobRepository.cs
| using System.Collections.Generic; | |
| using System.Threading.Tasks; | |
| using MongoDB.Driver; | |
| using TelegramSaaS.Application.Common.Interfaces.Persistence; | |
| using TelegramSaaS.Domain.Entities; | |
| namespace TelegramSaaS.Infrastructure.Persistence.Repositories; | |
| public class GenerationJobRepository : MongoRepository<GenerationJob>, IGenerationJobRepository | |
| { | |
| public GenerationJobRepository(MongoDbContext context) : base(context, "GenerationJobs") | |
| { | |
| } | |
| public async Task<IEnumerable<GenerationJob>> GetJobsByUserIdAsync(string userId, int limit = 20) | |
| { | |
| return await Collection.Find(x => x.UserId == userId) | |
| .SortByDescending(x => x.CreatedAt) | |
| .Limit(limit) | |
| .ToListAsync(); | |
| } | |
| public async Task<GenerationJob?> GetByProviderJobIdAsync(string providerJobId) | |
| { | |
| return await Collection.Find(x => x.ProviderJobId == providerJobId).FirstOrDefaultAsync(); | |
| } | |
| } | |