Fix sorting by relevance

This commit is contained in:
Michał Gątkowski 2022-08-10 01:04:29 +02:00
parent 08fd243a20
commit f69836ad09
3 changed files with 8 additions and 3 deletions

View File

@ -41,15 +41,18 @@ window.onload = function () {
query = queryInput.value query = queryInput.value
switch (sortDropdown.selectedIndex) { switch (sortDropdown.selectedIndex) {
case 0: case 0:
setOrderBy("RELEVANCE")
break;
case 1: case 1:
case 2:
setOrderBy("TOTAL_SIZE") setOrderBy("TOTAL_SIZE")
break; break;
case 2:
case 3: case 3:
case 4:
setOrderBy("DISCOVERED_ON") setOrderBy("DISCOVERED_ON")
break; break;
case 4:
case 5: case 5:
case 6:
setOrderBy("N_FILES") setOrderBy("N_FILES")
break; break;
} }

View File

@ -1,4 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<!--suppress ALL -->
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
@ -30,6 +31,7 @@
<div><a href="/"><b>magnetico<sup>w</sup></b></a>&#8203;<sub>(pre-alpha)</sub></div> <div><a href="/"><b>magnetico<sup>w</sup></b></a>&#8203;<sub>(pre-alpha)</sub></div>
<input id="query" type="search" name="query" placeholder="Search the BitTorrent DHT"> <input id="query" type="search" name="query" placeholder="Search the BitTorrent DHT">
<select id="sort-dropdown"> <select id="sort-dropdown">
<option value="size_asc">By relevance</option>
<option value="size_asc">By size (ascending)</option> <option value="size_asc">By size (ascending)</option>
<option value="size_desc">By size (descending)</option> <option value="size_desc">By size (descending)</option>
<option value="size_asc">By date (ascending)</option> <option value="size_asc">By date (ascending)</option>

View File

@ -298,7 +298,7 @@ func (db *postgresDatabase) QueryTorrents(
func orderOnPostgreSQL(orderBy OrderingCriteria) string { func orderOnPostgreSQL(orderBy OrderingCriteria) string {
switch orderBy { switch orderBy {
case ByRelevance: case ByRelevance:
return "relevance" return "similarity(name, 'twistys') * -1"
case ByTotalSize: case ByTotalSize:
return "total_size" return "total_size"