mirror of
https://github.com/postgres/pgweb.git
synced 2025-07-25 16:02:27 +00:00
Retire search for "community sites"
This hasn't worked for a few years (since 900946df
) and nobody has
complained. Getting rid of it allows similifying a few things on the
search server side as well.
This commit is contained in:
@ -1227,11 +1227,6 @@ button.btn.btn-default {
|
||||
|
||||
/* Input */
|
||||
|
||||
input#allsites {
|
||||
margin-top: 10px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
input.form-control {
|
||||
height: 2.5em;
|
||||
margin: auto 0;
|
||||
@ -1283,15 +1278,6 @@ th.formfieldnamecontainer {
|
||||
margin-top: .4rem;
|
||||
}
|
||||
|
||||
.form-check.search {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.form-check.search label.form-check-label {
|
||||
margin-left: 1rem;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.text-center.fixed-height h3 {
|
||||
height: 3.5em;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ def generate_pagelinks(pagenum, totalpages, querystring):
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
@queryparams('a', 'd', 'l', 'ln', 'm', 'p', 'q', 's', 'u')
|
||||
@queryparams('d', 'l', 'ln', 'm', 'p', 'q', 's', 'u')
|
||||
@cache(minutes=30)
|
||||
def search(request):
|
||||
# Perform a general web search
|
||||
@ -122,7 +122,6 @@ def search(request):
|
||||
else:
|
||||
searchlists = False
|
||||
suburl = request.GET.get('u', None)
|
||||
allsites = request.GET.get('a', None) == "1"
|
||||
|
||||
# Check that we actually have something to search for
|
||||
if request.GET.get('q', '') == '':
|
||||
@ -277,11 +276,10 @@ def search(request):
|
||||
|
||||
# perform the query for general web search
|
||||
try:
|
||||
curs.execute("SELECT * FROM site_search(%(query)s, %(firsthit)s, %(hitsperpage)s, %(allsites)s, %(suburl)s, %(internal)s)", {
|
||||
curs.execute("SELECT * FROM site_search(%(query)s, %(firsthit)s, %(hitsperpage)s, %(suburl)s, %(internal)s)", {
|
||||
'query': query,
|
||||
'firsthit': firsthit - 1,
|
||||
'hitsperpage': hitsperpage,
|
||||
'allsites': allsites,
|
||||
'suburl': suburl,
|
||||
'internal': include_internal,
|
||||
})
|
||||
@ -300,15 +298,13 @@ def search(request):
|
||||
quoted_suburl = ''
|
||||
except Exception as e:
|
||||
quoted_suburl = ''
|
||||
querystr = "?q=%s&a=%s&u=%s" % (
|
||||
querystr = "?q=%s&u=%s" % (
|
||||
urllib.parse.quote_plus(query.encode('utf-8')),
|
||||
allsites and "1" or "0",
|
||||
quoted_suburl,
|
||||
)
|
||||
|
||||
return render(request, 'search/sitesearch.html', {
|
||||
'suburl': suburl,
|
||||
'allsites': allsites,
|
||||
'hitcount': totalhits,
|
||||
'firsthit': firsthit,
|
||||
'lasthit': min(totalhits, firsthit + hitsperpage - 1),
|
||||
|
@ -17,12 +17,6 @@
|
||||
</button>
|
||||
</span>
|
||||
</div><!-- /input-group -->
|
||||
<div class="form-check search">
|
||||
<input class="form-check-input" type="checkbox" name="a" value="1" {%if allsites%}checked="checked"{%endif%} id="allsites">
|
||||
<label class="form-check-label" for="allsites">
|
||||
Include community sites
|
||||
</label>
|
||||
</div>
|
||||
</div><!-- /.col-lg-6 -->
|
||||
</div><!-- /.row -->
|
||||
</form>
|
||||
|
@ -60,7 +60,7 @@ LANGUAGE 'plpgsql';
|
||||
ALTER FUNCTION archives_search(text, int, timestamptz, timestamptz, int, int, char) SET default_text_search_config = 'public.pg';
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION site_search(query text, startofs int, hitsperpage int, allsites bool, _suburl text, includeinternal boolean DEFAULT False)
|
||||
CREATE OR REPLACE FUNCTION site_search(query text, startofs int, hitsperpage int, _suburl text, includeinternal boolean DEFAULT False)
|
||||
RETURNS TABLE (siteid int, baseurl text, suburl text, title text, headline text, rank float)
|
||||
AS $$
|
||||
DECLARE
|
||||
@ -80,16 +80,11 @@ BEGIN
|
||||
|
||||
hits := 0;
|
||||
|
||||
IF allsites THEN
|
||||
SELECT INTO pagecount sum(sites.pagecount) FROM sites;
|
||||
OPEN curs FOR SELECT sites.id AS siteid, sites.baseurl, webpages.suburl, ts_rank_cd(fti,tsq) * relprio AS ts_rank_cd FROM webpages INNER JOIN sites ON webpages.site=sites.id WHERE fti @@ tsq AND (includeinternal OR NOT isinternal) ORDER BY ts_rank_cd(fti,tsq) * relprio DESC LIMIT 1000;
|
||||
SELECT INTO pagecount sites.pagecount FROM sites WHERE id=1;
|
||||
IF _suburl IS NULL THEN
|
||||
OPEN curs FOR SELECT sites.id AS siteid, sites.baseurl, webpages.suburl, ts_rank_cd(fti,tsq) * relprio AS ts_rank_cd FROM webpages INNER JOIN sites ON webpages.site=sites.id WHERE fti @@ tsq AND site=1 AND (includeinternal OR NOT isinternal) ORDER BY ts_rank_cd(fti,tsq) * relprio DESC LIMIT 1000;
|
||||
ELSE
|
||||
SELECT INTO pagecount sites.pagecount FROM sites WHERE id=1;
|
||||
IF _suburl IS NULL THEN
|
||||
OPEN curs FOR SELECT sites.id AS siteid, sites.baseurl, webpages.suburl, ts_rank_cd(fti,tsq) * relprio AS ts_rank_cd FROM webpages INNER JOIN sites ON webpages.site=sites.id WHERE fti @@ tsq AND site=1 AND (includeinternal OR NOT isinternal) ORDER BY ts_rank_cd(fti,tsq) * relprio DESC LIMIT 1000;
|
||||
ELSE
|
||||
OPEN curs FOR SELECT sites.id AS siteid, sites.baseurl, webpages.suburl, ts_rank_cd(fti,tsq) * relprio AS ts_rank_cd FROM webpages INNER JOIN sites ON webpages.site=sites.id WHERE fti @@ tsq AND site=1 AND webpages.suburl LIKE _suburl||'%' AND (includeinternal OR NOT isinternal) ORDER BY ts_rank_cd(fti,tsq) * relprio DESC LIMIT 1000;
|
||||
END IF;
|
||||
OPEN curs FOR SELECT sites.id AS siteid, sites.baseurl, webpages.suburl, ts_rank_cd(fti,tsq) * relprio AS ts_rank_cd FROM webpages INNER JOIN sites ON webpages.site=sites.id WHERE fti @@ tsq AND site=1 AND webpages.suburl LIKE _suburl||'%' AND (includeinternal OR NOT isinternal) ORDER BY ts_rank_cd(fti,tsq) * relprio DESC LIMIT 1000;
|
||||
END IF;
|
||||
LOOP
|
||||
FETCH curs INTO hit;
|
||||
@ -106,4 +101,4 @@ BEGIN
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql';
|
||||
ALTER FUNCTION site_search(text, int, int, bool, text, bool) SET default_text_search_config = 'public.pg';
|
||||
ALTER FUNCTION site_search(text, int, int, text, bool) SET default_text_search_config = 'public.pg';
|
||||
|
Reference in New Issue
Block a user