Compare commits

..

No commits in common. "b71953fd1b8e07a81b93ac7fa95edf3b73439a92" and "f6690f2013b2fdedbc8dc20b061aa01134c497f4" have entirely different histories.

5 changed files with 10 additions and 20 deletions

View File

@ -182,7 +182,7 @@ class User():
else: else:
self.accessible_partitions = db.execute( self.accessible_partitions = db.execute(
""" """
SELECT DISTINCT partition.uuid, partition.name, SELECT partition.uuid, partition.name,
partition.author, partition.body, partition.author, partition.body,
partition.user_id, partition.source partition.user_id, partition.source
FROM partition FROM partition
@ -196,7 +196,7 @@ class User():
ON contient_user.user_id=? ON contient_user.user_id=?
AND album_id=album.id AND album_id=album.id
UNION UNION
SELECT DISTINCT album.id FROM album SELECT album.id FROM album
JOIN groupe_contient_user JOIN groupe_contient_user
JOIN groupe_contient_album JOIN groupe_contient_album
ON groupe_contient_user.user_id=? ON groupe_contient_user.user_id=?

View File

@ -10,7 +10,6 @@ import os
import pypdf import pypdf
import googlesearch import googlesearch
from unidecode import unidecode
from .db import get_db from .db import get_db
@ -21,20 +20,20 @@ def local_search(query, partitions):
""" """
Renvoie les 5 résultats les plus pertinents parmi une liste donnée Renvoie les 5 résultats les plus pertinents parmi une liste donnée
""" """
query_words = [word.lower() for word in unidecode(query).split()] query_words = [word.lower() for word in query.split(" ")]
def score_attribution(partition): def score_attribution(partition):
score = 0 score = 0
for word in query_words: for word in query_words:
if word != "": if word != "":
if word in unidecode(partition["name"]).lower(): if word in partition["name"].lower():
score += 6 score += 6
elif word in unidecode(partition["author"]).lower(): elif word in partition["author"].lower():
score += 4 score += 4
elif word in unidecode(partition["body"]).lower(): elif word in partition["body"].lower():
score += 2 score += 2
else: else:
score -= 6 score -= 1
for word in unidecode(partition["name"]).split(): for word in partition["name"].split(" "):
if word != "" and word.lower() not in query_words: if word != "" and word.lower() not in query_words:
score -= 1 score -= 1
return score return score

View File

@ -4,4 +4,3 @@ google
colorama colorama
pypdf pypdf
qrcode qrcode
unidecode

View File

@ -188,10 +188,3 @@ def install_babel():
def install_pypdf(): def install_pypdf():
utils.install_package("pypdf") utils.install_package("pypdf")
"""
v1.10.*
"""
def install_unidecode():
utils.install_package("unidecode")

View File

@ -37,7 +37,6 @@ hooks = [
("v1.5.1", [("Move thumbnails", v1_hooks.move_thumbnails)]), ("v1.5.1", [("Move thumbnails", v1_hooks.move_thumbnails)]),
("v1.7.0", [("Install babel", v1_hooks.install_babel)]), ("v1.7.0", [("Install babel", v1_hooks.install_babel)]),
("v1.8.2", [("Install pypdf", v1_hooks.install_pypdf)]) ("v1.8.2", [("Install pypdf", v1_hooks.install_pypdf)])
("v1.10.3", [("Install unidecode", v1_hooks.install_unidecode)])
] ]