def posts_by_page():
if request.method == 'GET':
topic = ast.literal_eval(request.args.get('topic'))
sources_ids = ast.literal_eval(request.args.get('sources'))
format_string = formatstring(sources_ids)
page = ast.literal_eval(request.args.get('page'))
fromDate = format_fromDate(ast.literal_eval(request.args.get('fromDate')))
toDate = format_toDate(ast.literal_eval(request.args.get('toDate')))
app.logger.info('GET posts_by_page: topic(%s), sources_ids(%s), page(%s), from(%s), to(%s)'
% ('%s', format_string, '%s', '%s', '%s')
% tuple([topic] + sources_ids + [page, fromDate, toDate]))
db = g.db
cur = db.cursor()
from_post_rnum = (page-1)*config['perpage']
get_post_between(cur, topic, sources_ids, from_post_rnum, config['perpage'], fromDate, toDate)
posts = [dict(id=int(row[0]), title=row[1], url=row[2], timestamp=row[3]) for row in cur.fetchall()]
post_ruleset_count_dic = get_post_ruleset_count_dic(cur, topic, sources_ids, from_post_rnum, config['perpage'], fromDate, toDate)
return jsonify(posts = posts,
post_ruleset_count_dic = post_ruleset_count_dic)
评论列表
文章目录