parent
87b34eb567
commit
dd72a355c7
|
@ -8,8 +8,7 @@ def create_app(test_config=None):
|
|||
app.config.from_mapping(
|
||||
SECRET_KEY='dev',
|
||||
#DATABASE=os.path.join(app.instance_path, 'flaskr.sqlite'),
|
||||
API='http://localhost:5000/',
|
||||
# API='http://sfr-bardo-copyright-development.us-east-1.elasticbeanstalk.com',
|
||||
API='http://sfr-bardo-copyright-development.us-east-1.elasticbeanstalk.com',
|
||||
)
|
||||
|
||||
if test_config is None:
|
||||
|
|
|
@ -1,16 +1,6 @@
|
|||
from flask import current_app, g
|
||||
import requests
|
||||
|
||||
def new_search(param, page=0, per_page=10):
|
||||
r = requests.get(current_app.config['API'] + '/search/multi',
|
||||
params={'title': param["title"],
|
||||
'authors': param["authors"],
|
||||
'publishers': param["publishers"],
|
||||
'source': 'true',
|
||||
'page': page,
|
||||
'per_page': per_page})
|
||||
return r.json()
|
||||
|
||||
def search(term, page=0, per_page=10):
|
||||
r = requests.get(current_app.config['API'] + '/search/fulltext',
|
||||
params={'query': term,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from cce_search.api import search, reg_search, ren_search, new_search, registration, renewal
|
||||
from cce_search.api import search, reg_search, ren_search, registration, renewal
|
||||
from flask import (
|
||||
Blueprint, flash, g, redirect, render_template, request, url_for
|
||||
)
|
||||
|
@ -21,8 +21,7 @@ def index():
|
|||
tempResults = None
|
||||
tempPaging = None
|
||||
tempArgs = None
|
||||
matched_results = []
|
||||
params = {}
|
||||
|
||||
unique = 0
|
||||
max_page = 0
|
||||
|
||||
|
@ -44,60 +43,45 @@ def index():
|
|||
paging = proc_pagination(results['data']['paging'], request.args.get('page'))
|
||||
unique = 1 #technically not 100% unique but should be very simplified for now
|
||||
|
||||
if request.args.get("title") and unique==0:
|
||||
params["title"] = request.args['title']
|
||||
else:
|
||||
params["title"] = "*"
|
||||
if request.args.get("title") and unique == 0:
|
||||
title = request.args['title']
|
||||
tempResults = search(title, request.args.get('page'),
|
||||
request.args.get('per_page'))
|
||||
tempPaging = proc_pagination(tempResults['data']['paging'],
|
||||
request.args.get('page'))
|
||||
max_page = tempPaging['last_page']
|
||||
results = tempResults
|
||||
paging = tempPaging
|
||||
tempArgs = request.args['title']
|
||||
|
||||
|
||||
if request.args.get("author") and unique == 0:
|
||||
params["authors"] = request.args['author']
|
||||
else:
|
||||
params["authors"] = "*"
|
||||
|
||||
if request.args.get("publisher") and unique==0:
|
||||
params['publishers'] = request.args['publisher']
|
||||
else:
|
||||
params["publishers"] = "*"
|
||||
|
||||
if unique==0:
|
||||
results = new_search(params, request.args.get('page'), request.args.get('per_page'))
|
||||
paging = proc_pagination(results['data']['paging'], request.args.get('page'))
|
||||
# if request.args.get("title") and unique == 0:
|
||||
# title = request.args['title']
|
||||
# tempResults = search(title, request.args.get('page'),
|
||||
# request.args.get('per_page'))
|
||||
# tempPaging = proc_pagination(tempResults['data']['paging'],
|
||||
# request.args.get('page'))
|
||||
# max_page = tempPaging['last_page']
|
||||
# results = tempResults
|
||||
# paging = tempPaging
|
||||
# tempArgs = request.args['title']
|
||||
|
||||
# if request.args.get("author") and unique == 0:
|
||||
# author = request.args['author']
|
||||
# tempResults = search(author, request.args.get('page'),
|
||||
# request.args.get('per_page'))
|
||||
# tempPaging = proc_pagination(tempResults['data']['paging'],
|
||||
# request.args.get('page'))
|
||||
# if max_page > tempPaging['last_page'] or max_page == 0:
|
||||
# max_page = tempPaging['last_page']
|
||||
# results = tempResults
|
||||
# paging = tempPaging
|
||||
# tempArgs = request.args['author']
|
||||
author = request.args['author']
|
||||
tempResults = search(author, request.args.get('page'),
|
||||
request.args.get('per_page'))
|
||||
tempPaging = proc_pagination(tempResults['data']['paging'],
|
||||
request.args.get('page'))
|
||||
if max_page > tempPaging['last_page'] or max_page == 0:
|
||||
max_page = tempPaging['last_page']
|
||||
results = tempResults
|
||||
paging = tempPaging
|
||||
tempArgs = request.args['author']
|
||||
|
||||
# if request.args.get("publisher") and unique == 0:
|
||||
# publisher = request.args['publisher']
|
||||
# tempResults = search(publisher, request.args.get('page'),
|
||||
# request.args.get('per_page'))
|
||||
# tempPaging = proc_pagination(tempResults['data']['paging'],
|
||||
# request.args.get('page'))
|
||||
# if max_page > tempPaging['last_page'] or max_page == 0:
|
||||
# max_page = tempPaging['last_page']
|
||||
# results = tempResults
|
||||
# paging = tempPaging
|
||||
# tempArgs = request.args['publisher']
|
||||
|
||||
# #Modifed Search Functionality
|
||||
if request.args.get("publisher") and unique == 0:
|
||||
publisher = request.args['publisher']
|
||||
tempResults = search(publisher, request.args.get('page'),
|
||||
request.args.get('per_page'))
|
||||
tempPaging = proc_pagination(tempResults['data']['paging'],
|
||||
request.args.get('page'))
|
||||
if max_page > tempPaging['last_page'] or max_page == 0:
|
||||
max_page = tempPaging['last_page']
|
||||
results = tempResults
|
||||
paging = tempPaging
|
||||
tempArgs = request.args['publisher']
|
||||
|
||||
#Modifed Search Functionality
|
||||
# matched_results = []
|
||||
# for i in range(max_page):
|
||||
# pageResults = proc_results(search(tempArgs, i, 10))
|
||||
# for obj in pageResults:
|
||||
|
@ -145,11 +129,11 @@ def index():
|
|||
# print(procResults)
|
||||
|
||||
|
||||
print("PRINTING PAGING HERE")
|
||||
print(paging)
|
||||
print("----------------------------------------------------------")
|
||||
print("DATA PAGING")
|
||||
print(results['data']['paging'])
|
||||
# print("PRINTING PAGING HERE")
|
||||
# print(paging)
|
||||
# print("----------------------------------------------------------")
|
||||
# print("DATA PAGING")
|
||||
# print(results['data']['paging'])
|
||||
results = proc_results(results)
|
||||
# print(json.dumps(results))
|
||||
|
||||
|
|
Loading…
Reference in New Issue