Alteração parcial no search do whatsapp cache
parent
bc406cb1d0
commit
408bb16e87
|
@ -6,6 +6,7 @@ var flatten = require('flat')
|
|||
import ListWhatsAppsNumber from "../services/WhatsappService/ListWhatsAppsNumber"
|
||||
import { redisConn } from './TicketCache'
|
||||
import Whatsapp from "../models/Whatsapp";
|
||||
import { response } from 'express'
|
||||
|
||||
const deleteWhatsappCache = async (hash:any) => {
|
||||
|
||||
|
@ -104,7 +105,7 @@ const updateWhatsappCacheById = async (hash:any, update_fields: object | any) =>
|
|||
// }
|
||||
|
||||
|
||||
async function searchWhatsappCache(search: string) {
|
||||
async function searchWhatsappCache(id: string, status: string) {
|
||||
|
||||
const redis: any = await redisConn();
|
||||
|
||||
|
@ -112,7 +113,18 @@ async function searchWhatsappCache(search: string) {
|
|||
|
||||
if (redis.status !== 'connect') return null
|
||||
|
||||
const response: any = await redis.call('FT.SEARCH', 'idx_whatsapp', `(@status:*${search}*)|(@number:*${search}*)`, 'SORTBY', 'status', 'ASC')
|
||||
// @x:foo @y:bar
|
||||
|
||||
// const response: any = await redis.call('FT.SEARCH', 'idx_whatsapp', `(@status:*${status}*) (@number:*${number}*)`, 'SORTBY', 'status', 'ASC')
|
||||
|
||||
// const response: any = await redis.call('FT.SEARCH', 'idx_whatsapp', `(@id:*${id}*))`)
|
||||
|
||||
const response: any = []
|
||||
|
||||
const number_cache: any = await redis.hgetall(`whatsapp:${14}`)
|
||||
|
||||
console.log('NUMBER CACHED: ', number_cache)
|
||||
|
||||
redis.quit()
|
||||
|
||||
|
||||
|
@ -220,7 +232,7 @@ const createWhatsappIndexCache = async (hashIndex: string) => {
|
|||
await redis.call('FT.DROPINDEX', hashIndex)
|
||||
}
|
||||
|
||||
const response = await redis.call('FT.CREATE', hashIndex, 'ON', 'HASH', 'PREFIX', '1', 'whatsapp:', 'SCHEMA', 'status', 'TEXT', 'SORTABLE', 'number', 'TEXT', 'SORTABLE')
|
||||
const response = await redis.call('FT.CREATE', hashIndex, 'ON', 'HASH', 'PREFIX', '1', 'whatsapp:', 'SCHEMA','id', 'NUMERIC', 'SORTABLE', 'status', 'TEXT', 'SORTABLE', 'number', 'TEXT')
|
||||
|
||||
console.log('Whatsapp index created: ', response)
|
||||
|
||||
|
|
Loading…
Reference in New Issue