Results works just takes a really long time

tmitchell
tmitche2 2020-04-30 13:22:32 -07:00
parent abce285814
commit 5f99a15ab7
3 changed files with 88 additions and 97 deletions

View File

@ -21,6 +21,9 @@ def index():
tempResults = None
tempPaging = None
tempArgs = None
matched_results = []
newResults = None
unique = 0
max_page = 0
@ -30,6 +33,7 @@ def index():
if not arguments:
print("NO ARGUMENTS GIVEN. PLEASE GIVE ARGUMENTS")
return render_template('search/index.html', results=results, term=title, paging=paging, search_type=search_type)
else:
if request.args.get("renewal"):
results = ren_search(request.args['renewal'], request.args.get('page'),
@ -81,52 +85,59 @@ def index():
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:
# match_author = False
# match_title = False
# match_publisher = False
# if(title!=None):
# if(re.search(title, obj['title'], re.IGNORECASE)):
# match_title = True
# else:
# match_title = True
# if("type" in obj):
# if(author!=None):
# if(re.search(author, obj['author'], re.IGNORECASE)):
# match_author = True
# else:
# match_author = True
# else:
# if(author!=None):
# for a in obj['authors']:
# if(re.search(author, a, re.IGNORECASE)):
# match_author = True
# break
# else:
# match_author = True
# if(publisher!=None):
# for p in obj['publishers']:
# if(re.search(publisher, p, re.IGNORECASE)):
# match_publisher = True
# break
# else:
# match_publisher = True
# if(match_author and match_title and match_publisher):
# matched_results.append(obj)
# print(json.dumps(matched_results))
# print(len(matched_results))
# if max_page != 0:
# print("----------------------------------------------------------")
# procResults = proc_results(search(tempArgs, 0, results['data']['total']))
# print(procResults)
for i in range(max_page):
pageResults = proc_results(search(tempArgs, i, 10))
for obj in pageResults:
match_author = False
match_title = False
match_publisher = False
if(title!=None):
if(re.search(title, obj['title'], re.IGNORECASE)):
match_title = True
else:
match_title = True
if("type" in obj):
if(author!=None):
if(re.search(author, obj['author'], re.IGNORECASE)):
match_author = True
else:
match_author = True
else:
if(author!=None):
for a in obj['authors']:
if(re.search(author, a, re.IGNORECASE)):
match_author = True
break
else:
match_author = True
if(publisher!=None):
for p in obj['publishers']:
if(re.search(publisher, p, re.IGNORECASE)):
match_publisher = True
break
else:
match_publisher = True
if(match_author and match_title and match_publisher):
matched_results.append(obj)
print(results)
print("__________________________________________________________")
print(json.dumps(matched_results))
print(type(matched_results))
print(len(matched_results))
#tempPaging = new_pagination(matched_results['data']['paging'], request.args.get('page'))
#print(tempPaging)
if max_page != 0:
print("----------------------------------------------------------")
#newResults = proc_results(matched_results)
procResults = proc_results(search(tempArgs, 0, results['data']['total']))
print(type(procResults))
# print("PRINTING PAGING HERE")
@ -142,8 +153,22 @@ def index():
noresults = 1
return render_template('search/index.html', noresults=noresults)
return render_template('search/index.html', results=results, term=title,
paging=paging, search_type=search_type)
if unique == 1:
return render_template('search/index.html', results=results, term=title,paging=paging, search_type=search_type)
return render_template('results.html', results=matched_results)
def new_pagination(pg, current):
if not pg['next'] and not pg['previous']:
return {**pg, **{'has_pages': False}}
per_page = extract_per_page(pg)
if current is None:
current = 1
else:
current = int(current) + 1
def proc_results(r):

View File

@ -5,6 +5,8 @@
{% endblock %}
{% block content %}
<div class="py-5 text-center">
<div class="content">
<p>The letters at the beginning of a registration number like “A1234”, or "BB4567" are the registration “class.” These classes mainly have to do with type or material of the work: “A” for books, “D” for dramas, “F” for maps, and so on. They may also indicate some other aspect of the work such as “DP” for a <em>published</em> drama or “DU” for an <em>unpublished</em> one.</p> Most of the entries in this dataset so far are “A” (books), and some sub-classes of class “A” are important to understand for determining copyright.</p>
<h3 id="foreign">Foreign Publications (AF, AFO)</h3>
@ -22,5 +24,5 @@
<p>“AI” and “AIO” are used English-language works published outside the United States. Unlike non-English works, these were subject to the “Manufacturing Clause” which required them to printed in the United States in order to gain US copyright protection. The interim registration secured temporary protection until an American edition could be printed. Like class AF, copyright was restored to most of these works after URAA<p>
<p>When an AI registration is followed by an American edition, the American edition receives an A-class registration. Therefore in determining the copyright if any book, it is important to determine whether there is a previous AI (or possibly AF) registration that would indicate restored rights.</p>
</div></div>
{% endblock %}

View File

@ -1,53 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% extends 'base.html' %}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<link rel="stylesheet" href="/static/styles.css">
{% block content %}
<head>
<title>Copyright Renewals</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand">Copyright Renewals</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="/">Search <span class="sr-only"></span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="about">About Us <span class="sr-only"></span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Copyrights <span class="sr-only"></span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">NYPL <span class="sr-only"></span></a>
</li>
</ul>
{% if results %}
{% for result in results %}
<div class="results">
{% if result['type'] %}
{% include "search/new_renewal.html" %}
{% else %}
{% include "search/new_registration.html" %}
{% endif %}
</div>
</nav>
{% endfor %}
{% endif %}
<div class="bg">
<div class="results">
<h1>Static Results page</h1>
</div>
</div>
</body>
</html>
{% endblock %}