aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-27 15:20:10 +0200
committerChocobozzz <me@florianbigard.com>2018-07-27 15:23:05 +0200
commitdbfd3e9bfef86bf935a24c9a325d9f06e3978b8f (patch)
treef1a7dfa26638b6cad649d12b6aaf0aa027bf0c3c /server/models/utils.ts
parenta3c1738eeaa3405d12c1c2f3102a24f3d15ebe3c (diff)
downloadPeerTube-dbfd3e9bfef86bf935a24c9a325d9f06e3978b8f.tar.gz
PeerTube-dbfd3e9bfef86bf935a24c9a325d9f06e3978b8f.tar.zst
PeerTube-dbfd3e9bfef86bf935a24c9a325d9f06e3978b8f.zip
Optimize search SQL query (I hope :p)
Diffstat (limited to 'server/models/utils.ts')
-rw-r--r--server/models/utils.ts14
1 files changed, 1 insertions, 13 deletions
diff --git a/server/models/utils.ts b/server/models/utils.ts
index 99e146583..58a18c97a 100644
--- a/server/models/utils.ts
+++ b/server/models/utils.ts
@@ -51,17 +51,6 @@ function createSimilarityAttribute (col: string, value: string) {
51 ) 51 )
52} 52}
53 53
54function createSearchTrigramQuery (col: string, value: string) {
55 return {
56 [ Sequelize.Op.or ]: [
57 // FIXME: use word_similarity instead of just similarity?
58 Sequelize.where(searchTrigramNormalizeCol(col), ' % ', searchTrigramNormalizeValue(value)),
59
60 Sequelize.where(searchTrigramNormalizeCol(col), ' LIKE ', searchTrigramNormalizeValue(`%${value}%`))
61 ]
62 }
63}
64
65// --------------------------------------------------------------------------- 54// ---------------------------------------------------------------------------
66 55
67export { 56export {
@@ -69,8 +58,7 @@ export {
69 getSortOnModel, 58 getSortOnModel,
70 createSimilarityAttribute, 59 createSimilarityAttribute,
71 throwIfNotValid, 60 throwIfNotValid,
72 buildTrigramSearchIndex, 61 buildTrigramSearchIndex
73 createSearchTrigramQuery
74} 62}
75 63
76// --------------------------------------------------------------------------- 64// ---------------------------------------------------------------------------