Skip to content

Commit

Permalink
Initial TACOS integration
Browse files Browse the repository at this point in the history
** Why are these changes being introduced:

* We are preparing to move our hints system into the TACOS application,
  in order to better respond to users' searches.

** Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/engx-267

** How does this address that need:

* This defines a new env variable, TACOS_URL, which stores the endpoint
  for the TACOS GraphQL service. When defined, the search results page
  will then direct the user agent to send the search string to the TACOS
  system, which will eventually respond with any additional information
  we can detect about the search string.

  For now, the only response will be to reflect the search string back
  into the console, along with the originating system.

* This new env has been added to the readme as an optional value.

** Document any side effects to this change:

* I'm adding a note to the 'confirming functionality' section about
  checking the browser console for the TACOS response.
  • Loading branch information
matt-bernhardt committed May 17, 2024
1 parent ace49a4 commit d7fd436
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ to construct thumbnail URLs.
- `RESULTS_PER_BOX`: defaults to 3
- `SENTRY_DSN`: logs exceptions to Sentry
- `SENTRY_ENV`: Sentry environment for the application. Defaults to 'unknown' if unset.
- `TACOS_URL`: The GraphQL endpoint for the [TACOS](https://github.com/mitlibraries/tacos/) application.
- `TIMDEX_TIMEOUT`: value to override the 6 second default for TIMDEX timeout.

## Confirming functionality after updating dependencies
Expand All @@ -94,4 +95,5 @@ bin/rails test

The following additional manual testing should be performed in the PR build on Heroku.

- search for a few different terms and confirm results return and are displayed in each of the boxes as appropriate. Not all boxes should return results for all searches, but comparing to production should lead to the same results (although there is a cache in production so if results don't match you might want to first clear the production cache before being overly concerned)
- Search for a few different terms and confirm results return and are displayed in each of the boxes as appropriate. Not all boxes should return results for all searches, but comparing to production should lead to the same results (although there is a cache in production so if results don't match you might want to first clear the production cache before being overly concerned)
- If the app is integrated with TACOS, the browser console should include a response from that system confirming the search string and source system.
12 changes: 12 additions & 0 deletions app/views/search/_trigger_tacos.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$.ajax({
type: "POST",
url: "<%= ENV.fetch('TACOS_URL', '') %>",
contentType: 'application/json',
data: '{ "query": "{ logSearchEvent( searchTerm: \\"<%= params[:q] %>\\" sourceSystem: \\"bento\\" ) { phrase source } }" }',
dataType: 'json'
}).success(function (msg) {
console.log(msg.data.logSearchEvent);
}).fail(function (xhr, textStatus ) {
console.log('Failure looking up search in Tacos:');
console.log(xhr);
});
5 changes: 5 additions & 0 deletions app/views/search/bento.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@
<%= render partial: "trigger_search", locals: { target: 'timdex', id: 'aspace_content'} %>

<%= render partial: "trigger_hint" %>

<% if ENV.has_key?('TACOS_URL') %>
<%= render partial: "trigger_tacos" %>
<% end %>

</script>

0 comments on commit d7fd436

Please sign in to comment.