重构
This commit is contained in:
24
hole.py
24
hole.py
@@ -357,15 +357,23 @@ def attention():
|
|||||||
def get_attention():
|
def get_attention():
|
||||||
u = require_token()
|
u = require_token()
|
||||||
|
|
||||||
ats = Attention.query.filter_by(
|
ats = Attention.query.with_entities(
|
||||||
name_hash=hash_name(
|
Attention.pid
|
||||||
u.name), disabled=False)
|
).filter_by(
|
||||||
|
name_hash=hash_name(u.name), disabled=False
|
||||||
|
).all()
|
||||||
|
|
||||||
posts = [Post.query.get(at.pid) for at in ats.all()]
|
pids = [pid for pid, in ats] or [0] # sql not allow empty in
|
||||||
data = [map_post(post, u.name, 10)
|
posts = Post.query.filter(
|
||||||
for post in posts[::-1]
|
Post.id.in_(pids)
|
||||||
if post and not post.deleted
|
).filter_by(
|
||||||
]
|
deleted=False
|
||||||
|
).order_by(Post.id.desc()).all()
|
||||||
|
|
||||||
|
data = [
|
||||||
|
map_post(post, u.name, 10)
|
||||||
|
for post in posts
|
||||||
|
]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'code': 0,
|
'code': 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user