aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--newspipe/controllers/article.py9
-rw-r--r--newspipe/templates/history.html6
2 files changed, 8 insertions, 7 deletions
diff --git a/newspipe/controllers/article.py b/newspipe/controllers/article.py
index 8468248e..bbb83b62 100644
--- a/newspipe/controllers/article.py
+++ b/newspipe/controllers/article.py
@@ -74,17 +74,18 @@ class ArticleController(AbstractController):
Sort articles by year and month.
"""
articles_counter = Counter()
- articles = self.read()
+ articles = self.read_light()
if year is not None:
articles = articles.filter(sqlalchemy.extract("year", Article.date) == year)
if month is not None:
articles = articles.filter(
sqlalchemy.extract("month", Article.date) == month
)
- for article in articles.all():
- if year is not None:
+ if year is not None:
+ for article in articles.all():
articles_counter[article.date.month] += 1
- else:
+ else:
+ for article in articles.all():
articles_counter[article.date.year] += 1
return articles_counter, articles
diff --git a/newspipe/templates/history.html b/newspipe/templates/history.html
index ba567106..0638993c 100644
--- a/newspipe/templates/history.html
+++ b/newspipe/templates/history.html
@@ -10,11 +10,11 @@
<h3>{{ year }}</h3>
{% endif %}
<ul class="list-group">
- {% for article in articles_counter | sort(reverse = True) %}
+ {% for date in articles_counter | sort(reverse = True) %}
{% if year == None %}
- <li class="list-group-item"><a href="{{ url_for("articles.history", year=article) }}">{{ article }}</a> : {{ articles_counter[article] }} articles</li>
+ <li class="list-group-item"><a href="{{ url_for("articles.history", year=date) }}">{{ date }}</a> : {{ articles_counter[date] }} articles</li>
{% elif month == None %}
- <li class="list-group-item"><a href="{{ url_for("articles.history", year=year, month=article) }}">{{ article | month_name }}</a> : {{ articles_counter[article] }} articles</li>
+ <li class="list-group-item"><a href="{{ url_for("articles.history", year=year, month=date) }}">{{ date | month_name }}</a> : {{ articles_counter[date] }} articles</li>
{% else %}
{% for article in articles %}
<li class="list-group-item">{{ article.date | datetime }} - <a href="/article/{{ article.id }}">{{ article.title | safe }}</a></li>
bgstack15