From d2d6af2cca3dc2b3b9399362865ff4d8a5a44ac8 Mon Sep 17 00:00:00 2001 From: Ching Date: Tue, 5 Oct 2021 16:03:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(DailyRecipe=20generate=5Frecipe):=20[M]=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96=E9=9A=8F=E6=9C=BA=E8=8F=9C?= =?UTF-8?q?=E8=B0=B1=E6=97=B6=E6=AD=BB=E5=BE=AA=E7=8E=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [M] 修复获取随机菜谱时死循环的问题 Signed-off-by: Ching --- recipe/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/recipe/models.py b/recipe/models.py index b332418..4a35f65 100644 --- a/recipe/models.py +++ b/recipe/models.py @@ -55,6 +55,8 @@ class DailyRecipe(models.Model): if recipe and recipe.id not in recipes and recipe.id not in prev_recipes: recipes.append(recipe.id) break + else: + retry -= 1 if retry <= 0: retry = 5 break @@ -68,7 +70,8 @@ class DailyRecipe(models.Model): if recipe and recipe.id not in recipes and recipe.id not in prev_recipes: recipes.append(recipe.id) break - retry -= 1 + else: + retry -= 1 if retry <= 0: retry = 5 break