nbr. hits
This commit is contained in:
parent
b7cc9ae915
commit
608467fdd8
@ -53,7 +53,7 @@ class Archive():
|
||||
return nbr_hits
|
||||
|
||||
|
||||
def search(self, keyword, field='content'):
|
||||
def search(self, keyword, field='content', min_hits=0):
|
||||
|
||||
search_results = { "keyword": keyword, "field": field, "archive": self.archive_name, "results": [] }
|
||||
|
||||
@ -68,7 +68,7 @@ class Archive():
|
||||
nbr_hits += self.search_message(keyword, m, current_index_str, hits, field)
|
||||
i += 1
|
||||
|
||||
if nbr_hits > 0:
|
||||
if nbr_hits > min_hits:
|
||||
# nettime-l - fix (the name of the thread from ex. 'nettime-l_Jan_01' to 'January 2001')
|
||||
if k.startswith("nettime-l_"):
|
||||
dt = datetime.strptime(k, "nettime-l_%b_%y")
|
||||
|
||||
@ -97,12 +97,13 @@ def searh():
|
||||
|
||||
if len(request.args) < 1:
|
||||
k = archives_data.keys()
|
||||
return render_template("search.html", archives=k, fields=['content', 'from(name)', 'from(email)'])
|
||||
return render_template("search.html", archives=k, fields=['content', 'from(name)', 'from(email)'], hits=['n/a', '2', '3', '4', '5', '6', '7', '8', '9'])
|
||||
|
||||
k_arg = request.args.get('keyword')
|
||||
l_arg = request.args.get('list')
|
||||
sl_arg = request.args.get('sublist')
|
||||
f_arg = request.args.get('field')
|
||||
h_arg = request.args.get('hits')
|
||||
|
||||
if k_arg is None or k_arg.strip() == '':
|
||||
return "no keyword..."
|
||||
@ -129,6 +130,12 @@ def searh():
|
||||
else:
|
||||
lists.append(l_arg)
|
||||
|
||||
nbr_hits = 0
|
||||
if h_arg in ['2', '3', '4', '5', '6', '7', '8', '9']:
|
||||
nbr_hits = int(h_arg)
|
||||
|
||||
|
||||
|
||||
################################
|
||||
##
|
||||
## need to cache all the below
|
||||
@ -145,7 +152,7 @@ def searh():
|
||||
# a = search.archive.Archive()
|
||||
# a.load(l)
|
||||
|
||||
results.append(archives_data[l].search(keyword=k_arg, field=f_arg))
|
||||
results.append(archives_data[l].search(keyword=k_arg, field=f_arg, min_hits=nbr_hits))
|
||||
|
||||
## -- sort results?
|
||||
search_results = sorted(results, key=get_result_key)
|
||||
|
||||
@ -20,6 +20,11 @@
|
||||
<option value="{{ a }}">{{ a }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<select form="search" name="hits">
|
||||
{% for a in hits %}
|
||||
<option value="{{ a }}">{{ a }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="submit" value="search" id="submit">
|
||||
<div id="loading">Loading...</div>
|
||||
</form>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user