def person_top(request): """ :param request: :return: """ sqlquery = """SELECT COUNT(id) AS mentions,name FROM persons GROUP BY name ORDER BY mentions DESC;""" return DbHelper.get_multiple_records(sqlquery)
def get_articles_by_date(date): """ :param date: :return: """ logging.info('Looking news for %s', date) articles = DbHelper.get_multiple_records( settings.CLUSTERING_QUERY_GET_NEWS % date) logging.info('Total news found: %s', len(articles)) return articles
def person_list(limit=10): """ :param limit: :return: """ if limit < 1: limit = 10 sqlquery = """SELECT COUNT(id) AS mentions,name FROM persons WHERE valid=True GROUP BY name ORDER BY mentions DESC LIMIT %s;""" % str(limit) return DbHelper.get_multiple_records(sqlquery)
def user_list(limit=10): """ :param limit: :return: """ if limit < 1: limit = 10 sqlquery = """SELECT id, username, created FROM api_users GROUP BY id, username, created ORDER BY created DESC LIMIT %s;""" % str(limit) return DbHelper.get_multiple_records(sqlquery)
def get_articles_by_date(date): """ :param date: :return: list(List of RankedArticle) """ logging.info('Looking news for %s', date) news = DbHelper.get_multiple_records( settings.RANKING_QUERY_GET_NEWS_BY_DATE % date) if news: logging.info('Total news found: %s', len(news)) return news else: raise ValueError('No news found')
def person_filter(request): """ :param request: :return: """ persons = None name_value = request.args.get('name') if name_value and len(name_value) > 1: name_value = name_value.replace("'", "''") sqlquery = """SELECT COUNT(id) AS mentions,name FROM persons WHERE name='%s' AND valid=True GROUP BY name ORDER BY mentions DESC;""" % \ name_value persons = DbHelper.get_multiple_records(sqlquery) return persons