Exemple #1
0
def history(user_id, year=None, month=None):
    """
    Sort articles by year and month.
    """
    articles_counter = Counter()
    articles = ArticleController(user_id).read()
    if None != year:
        articles = articles.filter(sqlalchemy.extract('year', 'Article.date') == year)
        if None != month:
            articles = articles.filter(sqlalchemy.extract('month', 'Article.date') == month)
    for article in articles.all():
        if None != year:
            articles_counter[article.date.month] += 1
        else:
            articles_counter[article.date.year] += 1
    return articles_counter, articles
Exemple #2
0
def history(user_id, year=None, month=None):
    """
    Sort articles by year and month.
    """
    articles_counter = Counter()
    articles = ArticleController(user_id).read()
    if None != year:
        articles = articles.filter(
            sqlalchemy.extract("year", "Article.date") == year)
        if None != month:
            articles = articles.filter(
                sqlalchemy.extract("month", "Article.date") == month)
    for article in articles.all():
        if None != year:
            articles_counter[article.date.month] += 1
        else:
            articles_counter[article.date.year] += 1
    return articles_counter, articles