fix(DailyRecipe generate_recipe): [M] 修复当获取不到随机菜谱时报错的问题
[M] 修复当获取不到随机菜谱时报错的问题 Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
parent
996f20498f
commit
6887140a4e
@ -52,7 +52,7 @@ class DailyRecipe(models.Model):
|
||||
recipe = Recipe.objects.filter(
|
||||
recipe_type=const.RECIPE_TYPE_MEAT,
|
||||
).order_by('?').first()
|
||||
if recipe.id not in recipes and recipe.id not in prev_recipes:
|
||||
if recipe and recipe.id not in recipes and recipe.id not in prev_recipes:
|
||||
recipes.append(recipe.id)
|
||||
break
|
||||
if retry <= 0:
|
||||
@ -65,7 +65,7 @@ class DailyRecipe(models.Model):
|
||||
recipe = Recipe.objects.filter(
|
||||
recipe_type=const.RECIPE_TYPE_VEGETABLE,
|
||||
).order_by('?').first()
|
||||
if recipe.id not in recipes and recipe.id not in prev_recipes:
|
||||
if recipe and recipe.id not in recipes and recipe.id not in prev_recipes:
|
||||
recipes.append(recipe.id)
|
||||
break
|
||||
retry -= 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user