From cfe1d60fabd6298715e714b585474fcb33e36dd3 Mon Sep 17 00:00:00 2001 From: Tdxdxoz Date: Fri, 5 Nov 2021 01:56:32 +0800 Subject: [PATCH] fix: choose next one --- app.py | 2 +- init_data.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index ce7e779..21f07dc 100644 --- a/app.py +++ b/app.py @@ -94,7 +94,7 @@ class Reaction(db.Model): def choose_new_next(min_like_num=10): for story in Story.query.filter_by(is_tree=False).all(): - last_paragraph_id = Story.tail + last_paragraph_id = story.tail next_one = Paragraph.query.filter_by(parent_id=last_paragraph_id, is_hidden=False)\ .order_by(Paragraph.like_num.desc()).first() if next_one and next_one.like_num >= min_like_num: diff --git a/init_data.py b/init_data.py index 31d889f..a812390 100644 --- a/init_data.py +++ b/init_data.py @@ -57,7 +57,7 @@ BEGIN_WORDS = [ ] for idx, (title, text, avatar) in zip(range(1, 11), BEGIN_WORDS): - s = Story(id=idx, title=title, text=text, tail=idx, + s = Story(id=idx, title=title, text=text, tail=idx, is_tree=(idx == 10), avatar="/ordinary/static/img/" + avatar) p = Paragraph(id=idx, text=text, story_id=idx, is_chosen=True, author="初始设定")