From 4be4f98f70144fb1e1aaec6b8fa3033196e292b3 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Thu, 21 Nov 2013 18:48:06 +0100 Subject: Added an option to index all the database. --- pyaggr3g470r/search.py | 3 +-- pyaggr3g470r/templates/management.html | 1 + pyaggr3g470r/views.py | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pyaggr3g470r/search.py b/pyaggr3g470r/search.py index 56aef3f6..4a8df1d9 100644 --- a/pyaggr3g470r/search.py +++ b/pyaggr3g470r/search.py @@ -47,11 +47,10 @@ schema = Schema(title=TEXT(stored=True), \ article_id=TEXT(stored=True), \ feed_id=TEXT(stored=True)) -def create_index(): +def create_index(feeds): """ Creates the index. """ - feeds = models.Feed.objects() if not os.path.exists(indexdir): os.makedirs(indexdir) ix = create_in(indexdir, schema) diff --git a/pyaggr3g470r/templates/management.html b/pyaggr3g470r/templates/management.html index 61da8943..8647f2e3 100644 --- a/pyaggr3g470r/templates/management.html +++ b/pyaggr3g470r/templates/management.html @@ -5,6 +5,7 @@

Your subscriptions

You are subscribed to {{ nb_feeds }} feeds. Add a feed.

{{ nb_articles }} articles are stored in the database with {{ nb_unread_articles }} unread articles.

+ Index database {% endblock %} \ No newline at end of file diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 991e25b0..1990633a 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -221,6 +221,16 @@ def inactives(): inactives.append((feed, elapsed)) return render_template('inactives.html', inactives=inactives, nb_days=nb_days) +@app.route('/index_database/', methods=['GET']) +@login_required +def index_database(): + """ + Index all the database. + """ + user = models.User.objects(email=g.user.email).first() + fastsearch.create_index(user.feeds) + return redirect(url_for('home')) + @app.route('/search/', methods=['GET']) @login_required def search(): -- cgit