Skip to content

Commit

Permalink
only query db if the list is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxiao921 committed Sep 20, 2021
1 parent d86700b commit 5140a2e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions CHEF/Components/Commands/Cooking/CookModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@ private async Task ListRecipesInternal(SocketUser owner = null, int page = 1, st
}
}

using (var context = new RecipeContext())
if (badRecipes.Count > 0)
{
context.RemoveRange(badRecipes);
using (var context = new RecipeContext())
{
context.RemoveRange(badRecipes);

await context.SaveChangesAsync();
await context.SaveChangesAsync();

Logger.Log($"Removed {badRecipes.Count} bad recipes.");
Logger.Log($"Removed {badRecipes.Count} bad recipes.");
}
}

if (recipes.Count > 0)
Expand Down

0 comments on commit 5140a2e

Please sign in to comment.