Browse Source

remove outdated predict routes, use jsonify for search results

master
wes 8 years ago
parent
commit
625579bd5f
  1. 6
      src/search.py
  2. 24
      src/website.py

6
src/search.py

@ -5,7 +5,7 @@ import elasticsearch
from elasticsearch_dsl import FacetedSearch, Search, Q from elasticsearch_dsl import FacetedSearch, Search, Q
from elasticsearch_dsl.aggs import Terms, DateHistogram from elasticsearch_dsl.aggs import Terms, DateHistogram
from sys import exit, stderr from sys import exit, stderr
from json import dumps, loads from json import loads
from itertools import chain from itertools import chain
from hashlib import sha1 from hashlib import sha1
@ -175,7 +175,7 @@ def searchTerms(terms):
if not qs: if not qs:
# No queries = no results # No queries = no results
return dumps([]) return []
# Reduce joins all of the queries into one query # Reduce joins all of the queries into one query
# It will search for the conjunction of all of them # It will search for the conjunction of all of them
@ -214,7 +214,7 @@ def searchTerms(terms):
secs["books"] = "" secs["books"] = ""
results.append(secs) results.append(secs)
return dumps(results) return results
searchers = { searchers = {

24
src/website.py

@ -63,27 +63,6 @@ def ClassSearch(configfile=None):
return send_from_directory("/srv/http/goal/favicon.ico", return send_from_directory("/srv/http/goal/favicon.ico",
'favicon.ico', mimetype='image/vnd.microsoft.icon') 'favicon.ico', mimetype='image/vnd.microsoft.icon')
@blueprint.route("/buildpred", methods=("GET", "POST"))
def buildpred():
return predictbuild(request)
@blueprint.route("/locpred", methods=("GET", "POST"))
def locpred():
return predictloc(request)
@blueprint.route("/daypred", methods=("GET", "POST"))
def daypred():
return predictday(request)
@blueprint.route("/deptpred", methods=("GET", "POST"))
def deptpred():
return predictdept(request)
@blueprint.route("/titlepred", methods=("GET", "POST"))
def titlepred():
return predicttitle(request)
@blueprint.route("/", methods=("GET", "POST")) @blueprint.route("/", methods=("GET", "POST"))
def index(): def index():
return render_template("search.html") return render_template("search.html")
@ -96,8 +75,7 @@ def ClassSearch(configfile=None):
for key, val in params.items(): for key, val in params.items():
if val in defaults: if val in defaults:
del params[key] del params[key]
results = searchTerms(params) return jsonify(searchTerms(params))
return results
@blueprint.route("/resources", methods=("GET", "POST")) @blueprint.route("/resources", methods=("GET", "POST"))
def resources(): def resources():

Loading…
Cancel
Save