]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/utils.ts
Add local user subscriptions
[github/Chocobozzz/PeerTube.git] / server / models / utils.ts
index 99e14658326adb5fb3fdb5d4dafcae8a625c9832..eb6653f3ddf24d906c4333a7856fd26d8923618c 100644 (file)
@@ -1,6 +1,8 @@
 // Translate for example "-name" to [ [ 'name', 'DESC' ], [ 'id', 'ASC' ] ]
 import { Sequelize } from 'sequelize-typescript'
 
+type SortType = { sortModel: any, sortValue: string }
+
 function getSort (value: string, lastSort: string[] = [ 'id', 'ASC' ]) {
   let field: any
   let direction: 'ASC' | 'DESC'
@@ -51,26 +53,15 @@ function createSimilarityAttribute (col: string, value: string) {
   )
 }
 
-function createSearchTrigramQuery (col: string, value: string) {
-  return {
-    [ Sequelize.Op.or ]: [
-      // FIXME: use word_similarity instead of just similarity?
-      Sequelize.where(searchTrigramNormalizeCol(col), ' % ', searchTrigramNormalizeValue(value)),
-
-      Sequelize.where(searchTrigramNormalizeCol(col), ' LIKE ', searchTrigramNormalizeValue(`%${value}%`))
-    ]
-  }
-}
-
 // ---------------------------------------------------------------------------
 
 export {
+  SortType,
   getSort,
   getSortOnModel,
   createSimilarityAttribute,
   throwIfNotValid,
-  buildTrigramSearchIndex,
-  createSearchTrigramQuery
+  buildTrigramSearchIndex
 }
 
 // ---------------------------------------------------------------------------