diff options
-rw-r--r-- | pyaggr3g470r/search.py | 3 | ||||
-rw-r--r-- | pyaggr3g470r/templates/management.html | 1 | ||||
-rw-r--r-- | 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 @@ <h1>Your subscriptions</h1> <p>You are subscribed to {{ nb_feeds }} <a href="/feeds">feeds</a>. Add a <a href="/edit_feed/">feed</a>.</p> <p>{{ nb_articles }} articles are stored in the database with {{ nb_unread_articles }} <a href="/unread/">unread articles</a>.</p> + <a href="/index_database/" class="btn btn-default">Index database</a> </div> </div><!-- /.container --> {% 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(): |