Skip to content

Commit

Permalink
fix get critical plants not returning only the latest condition log, …
Browse files Browse the repository at this point in the history
…resulting in wrong latest mood being returned
  • Loading branch information
juuwel committed May 28, 2024
1 parent 69fdce1 commit 91b0064
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Infrastructure/Repositories/PlantRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public async Task<List<Plant>> GetCriticalPlants(string requesterEmail)
await using var context = await dbContextFactory.CreateDbContextAsync();
return await context.Plants
.Include(plant => plant.Requirements)
.Include(plant => plant.ConditionsLogs)
.Include(plant => plant.ConditionsLogs.OrderByDescending(log => log.TimeStamp).Take(1))
.Where(p => p.UserEmail == requesterEmail && p.ConditionsLogs.Count != 0)
.Select(p => new
{
Expand All @@ -114,6 +114,7 @@ public async Task<List<Plant>> GetCriticalPlants(string requesterEmail)
.Select(p => p.Plant)
.ToListAsync();
}

public async Task<Stats> GetStats(string userEmail)
{
await using var context = await dbContextFactory.CreateDbContextAsync();
Expand Down

0 comments on commit 91b0064

Please sign in to comment.