| | |
| | | } |
| | | else { |
| | | const ids = searchLib.search(search) |
| | | if (!ids.length) return getUserSearchQuery(offset, limit) // nothing found |
| | | // if (!ids.length) return getUserSearchQuery(offset, limit) // nothing found |
| | | return `SELECT ${sel} |
| | | FROM ${database}.usr_data AS ud |
| | | WHERE login REGEXP '^[0-9]+$' |
| | |
| | | const _ = require("lodash") |
| | | const {Index, Document, Worker} = require("flexsearch") |
| | | const settings = require("../settings") |
| | | const fs = require("node:fs") |
| | | |
| | | ///////////////////////////////////////////////////////////////////////// |
| | | |
| | | // Message index |
| | | const options = { |
| | | tokenize: "full", |
| | | // tokenize: "full", |
| | | tokenize: "forward", |
| | | split: true, |
| | | } |
| | | |
| | |
| | | // .then(console.log) |
| | | // .catch(console.error) |
| | | |
| | | async function run() { |
| | | async function run () { |
| | | await doIndex() |
| | | console.log(search("latu")) |
| | | } |
| | |
| | | async function doIndex () { |
| | | const start = Date.now() |
| | | console.log("++ START indexing Users...") |
| | | let users = require("../users.json") |
| | | // users = users.slice(10) |
| | | |
| | | const {readFromFile, file} = settings.search |
| | | |
| | | let users |
| | | if (readFromFile) { |
| | | users = fs.readFileSync(file, "utf8") |
| | | users = JSON.parse(users) |
| | | } |
| | | else { |
| | | // TODO zweite möglichkeit "readFromApi" implementieren |
| | | } |
| | | |
| | | for (const user of users) { |
| | | addUser(user) |
| | |
| | | /////// idxMessage FNS //////////////////////////////////////////////////////////////// |
| | | |
| | | function getUserString (user) { |
| | | const {usr_id, firstname, lastname} = user |
| | | return `${usr_id} ${firstname} ${lastname}`.trim() |
| | | const {usr_id, firstname, lastname, institution, department} = user |
| | | return `${usr_id} ${firstname} ${lastname} ${institution} ${department}`.trim() |
| | | // return `${usr_id} ${firstname} ${lastname}`.trim() |
| | | } |
| | | |
| | | function addUser (user) { |
| | |
| | | "database": "ilias", |
| | | "user": "root", |
| | | "password": "paaa322ss" |
| | | }, |
| | | "search": { |
| | | "readFromFile": true, |
| | | "file": "users-local.json" |
| | | } |
| | | } |
| | |
| | | white-space nowrap |
| | | |
| | | |
| | | input[type=text], input[type=password] |
| | | padding .11em .22em |
| | | border 3px solid #aaa |
| | | &:focus |
| | | border 3px solid orange |
| | | outline none |
| | | |
| | |
| | | const limit = 22 |
| | | const error = ref(null) |
| | | |
| | | onMounted(() => init(offset.value)) |
| | | onMounted(() => init(offset.value, search.value)) |
| | | |
| | | /////// SEARCH //////////////////////////////////////////////////////////////// |
| | | |
| | | const search = useRouteQuery("search", "",)// {transform: s => s.trim()}) |
| | | async function _doSearch (search) { |
| | | console.log("doSEarch", search) |
| | | // return init(0, search) |
| | | // TODO offset muss zurückgesetzt werden wenn die Suche neu ist |
| | | return init(offset.value, search) |
| | | } |
| | | const doSearch = useDebounceFn(_doSearch, 500) |
| | | const doSearch = useDebounceFn(_doSearch, 333) |
| | | |
| | | ///////////////////////////////////////////////////////////////////////// |
| | | |