Trial - boosting prospect grid loading performance
This commit is contained in:
@@ -115,18 +115,24 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
.Include(x => x.Images)
|
||||
.Include(x => x.Interactions.OrderBy(i => i.Date)).ThenInclude(x => x.User)
|
||||
.OrderBy(x => x.Name).AsQueryable();
|
||||
|
||||
if(parameter.MustHaveInteractions != null && parameter.MustHaveInteractions.Any())
|
||||
|
||||
if (parameter.MustHaveInteractions != null && parameter.MustHaveInteractions.Any())
|
||||
prospectsQuery = prospectsQuery.Where(x => x.Interactions.Any(i => parameter.MustHaveInteractions.Contains(i.Type)));
|
||||
|
||||
if(parameter.CannotHaveInteractions != null && parameter.CannotHaveInteractions.Any())
|
||||
|
||||
if (parameter.CannotHaveInteractions != null && parameter.CannotHaveInteractions.Any())
|
||||
prospectsQuery = prospectsQuery.Where(x => x.Interactions.All(i => !parameter.CannotHaveInteractions.Contains(i.Type)));
|
||||
|
||||
if (!parameter.IncludeDeleted)
|
||||
if (!parameter.IncludeDeleted)
|
||||
prospectsQuery = prospectsQuery.Where(x => x.RecordState != RecordState.Archived);
|
||||
|
||||
|
||||
if (parameter.Skip > 0)
|
||||
prospectsQuery = prospectsQuery.Skip(parameter.Skip);
|
||||
|
||||
if (parameter.Take > 0)
|
||||
prospectsQuery = prospectsQuery.Take(parameter.Take);
|
||||
|
||||
var prospects = await prospectsQuery.ToListAsync();
|
||||
|
||||
|
||||
return new(prospects);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
Reference in New Issue
Block a user