Skip to content

Commit

Permalink
feat: improve query handling with general-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarpl committed Aug 15, 2023
1 parent 83b5c95 commit 42e02cb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion client/agents/general/general-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const REQUESTS = {
path: paths.SEARCH,

Check failure on line 9 in client/agents/general/general-agent.js

View workflow job for this annotation

GitHub Actions / Build, lint and test

Insert `␍`
params: {

Check failure on line 10 in client/agents/general/general-agent.js

View workflow job for this annotation

GitHub Actions / Build, lint and test

Insert `␍`
TITLE: 'title',
CREATED: 'created'
CREATED: 'created',
POOL_ID: 'poolId'
}
}
}
Expand All @@ -35,6 +36,7 @@ class GeneralAgent {
* @param {object} criteria - query criteria
* @param {string} criteria.title - clip title criteria. * is allowed as a wildcard
* @param {string} criteria.created - scope the search to clips created in a specific period
* @param {string} criteria.poolId - optional poolId to be forwarded to the backend search agent
*
* @returns {Promise} - a promise containing the search results
*/
Expand All @@ -46,6 +48,7 @@ class GeneralAgent {
url.pathname = url.pathname + path
url.searchParams.append(params.TITLE, criteria?.title)
url.searchParams.append(params.CREATED, criteria?.created)
url.searchParams.append(params.POOL_ID, criteria?.poolId)

return fetch(url.href).then((response) => {
if (response.ok) {
Expand Down
4 changes: 2 additions & 2 deletions client/ui/search-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ let isVisible = isNowVisible()
let lastTimeout = null

export async function init(server, poolId, refreshInterval, { onResults }) {
const quantelAgent = new QuantelAgent(server, poolId)
const quantelAgent = new QuantelAgent(server)
let firstQuery = true

function setQuery(query) {
lastQuery = Object.assign({}, query)
lastQuery = Object.assign({}, query, { poolId })

clearTimeout(lastTimeout)
performSearch(
Expand Down
3 changes: 2 additions & 1 deletion server/agents/casparcg-scanner/casparcg-scanner-agent.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ function filterClipResults(title, created, results) {
LAST_365_DAYS: last365Days.getTime()
}

const nameFilter = new RegExp(title.replace(/\*+/gi, '[\\S]+'), 'i')
// try and replicate SOLR wildcard behavior using RegExp
const nameFilter = new RegExp('^' + title.replace(/\*+/gi, '[\\S]+') + '$', 'i')

return results.filter((clipInfo) => {
if (clipInfo.time < PERIOD_PRESETS[created]) return false
Expand Down

0 comments on commit 42e02cb

Please sign in to comment.