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
switch (sortDropdown.selectedIndex) {
case 0:
setOrderBy("RELEVANCE")
break;
case 1:
case 2:
setOrderBy("TOTAL_SIZE")
break;
case 2:
case 3:
case 4:
setOrderBy("DISCOVERED_ON")
break;
case 4:
case 5:
case 6:
setOrderBy("N_FILES")
break;
}

View File

@ -1,4 +1,5 @@
<!DOCTYPE html>
<!--suppress ALL -->
<html lang="en">
<head>
<meta charset="utf-8">
@ -30,6 +31,7 @@
<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">
<select id="sort-dropdown">
<option value="size_asc">By relevance</option>
<option value="size_asc">By size (ascending)</option>
<option value="size_desc">By size (descending)</option>
<option value="size_asc">By date (ascending)</option>

View File

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