def fetch_comment_id(ili_ids, u=None):
"""
This function takes a list of ili ids and, optionally a username.
It returns a dictionary with the comments filtered by the ids and,
if provided, for that specific user.
"""
comments = dd(list)
ili_list = (",".join("?" for s in ili_ids), ili_ids)
if u:
for r in query_omw("""SELECT id, ili_id, com, u, t
FROM ili_com
WHERE ili_id in ({})
AND u = ?""".format(ili_list[0]),
ili_list[1]+[u]):
comments[r['ili_id']].append((r['com'], r['u'], r['t']))
else:
for r in query_omw("""SELECT id, ili_id, com, u, t
FROM ili_com
WHERE ili_id in ({})
""".format(ili_list[0]),
ili_list[1]):
comments[r['ili_id']].append((r['com'], r['u'], r['t']))
return comments
评论列表
文章目录