def domain_today(): data = Domain.get_all() result = [] total = 0 for item in data: article_new = Article.count(item['domain'], today=True) result.append({'domain': item['domain'], 'article_num': article_new}) total += article_new result = sorted(result, key=lambda k: k['article_num'], reverse=True) return jsonify(article_total=total, data=result)
def domain_today(): data = Domain.get_all() result = [] total = 0 for item in data: article_new = Article.count(item['domain'], today=True) result.append({ 'domain': item['domain'], 'article_num': article_new }) total += article_new result = sorted(result, key=lambda k: k['article_num'], reverse=True) return jsonify(article_total=total, data=result)
def domain_all(): data = Domain.get_all() total = sum(item['article_num'] for item in data) data = sorted(data, key=lambda k: k['article_num'], reverse=True) return jsonify(article_total=total, data=data)