-
Notifications
You must be signed in to change notification settings - Fork 0
Enable TACOS integration #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Pull Request Test Coverage Report for Build 18319309158Details
💛 - Coveralls |
196be47
to
6a14fb5
Compare
6a14fb5
to
7e79cd3
Compare
7e79cd3
to
425e623
Compare
** Why are these changes being introduced: The search UI needs to be connected with TACOS, in order to get insight about interventions and allow term categorization to continue. ** Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/use-66 ** How does this address that need: This adds a route, controller, and model for the integration with TACOS, along with defining some new environment variables. The approach is similar, but not identical, to the integration present in the Bento app. ** Document any side effects to this change: One oddity I can't explain is why the "tacos" cassette doesn't have any record of a call to TACOS - only the call to TIMDEX for the requested search is present. The related test passes, so everything worked and the UI element is present - but no interaction is present in the cassette (and thus made by the application when tested).
** Why are these changes being introduced: I realized that the Tacos model as originally proposed had no error handling when I refreshed a results page without my local TACOS app running. The result was a pretty ugly blob shown to the user. ** Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/use-66 ** How does this address that need: This adds two catch statements to the call to TACOS - one for an HTTP error response, and one for a JSON parsing error. It also refactors the Tacos model to allow a separately-defined HTTP object, which we craft in the test suite to always return those two error conditions. ** Document any side effects to this change: This is yet another pattern for error handling, not using VCR cassettes or webmock, neither of which I could get working this afternoon. I'm not happy about that, but this does work.
f570f78
to
720ff31
Compare
app/helpers/application_helper.rb
Outdated
@@ -1,4 +1,9 @@ | |||
module ApplicationHelper | |||
def tacos_enabled? | |||
ENV.fetch('TACOS_URL', '').length > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENV.fetch('TACOS_URL', '').present?
is more idiomatic in our codebase. (A blank string is not present, yeah it's sort of weird but also kind of makes sense)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm generally happy to go with the idiomatic approach, unless it doesn't work
app/models/tacos.rb
Outdated
# The tacos_client argument here is unused in production - it is provided for | ||
# our test suite so that we can mock various error conditions to ensure that | ||
# error handling happens as we intend. | ||
def self.call(term, tacos_client = nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of the method name call
here. Running any method is calling
it so naming something call
feels like we are calling the call method and my brain stops working.
Alternative ideas:
- align it with the Controller name of
analyze
- align it with TACOS graphQL method
logSearchEvent
- align it with an abbreviated TACOS
log
I think I prefer the first of those, analyze
because the logging returns data based on analysis. So naming this Tacos.analyze
feels like saying Hey Tacos, can you analyze this string
which feels pretty good to me.
This is not blocking per se, but I would encourage you to consider if there are better name options (whether it is one I suggested or not).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not particularly devoted to .call
as a method name - I think I inherited this when I grabbed the class from Bento. I'll take a quick look in context, but initially I like .analyze
app/models/tacos.rb
Outdated
end | ||
|
||
def self.tacos_source | ||
ENV.fetch('TACOS_SOURCE', 'unset') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are you thoughts on the default here being timdexui_unset
or useui_unset
instead of just unset
?
My thinking is this may help us in the future understand if we are seeing a lot of odd source data at least which code base it is coming from so we can more quickly track down which deployed system has incorrect config.
Non-blocking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, I like this suggestion - having a value that's specific to the codebase as a fallback should an instance-specific value not be defined feels pretty good. Thanks, will change.
* Use more idiomatic .present? method in tacos_enabled? helper * Update the default TACOS_SOURCE value to be specific to this codebase, rather than a generic "unset" * Rename the Tacos model method .call to .analyze
Okay @JPrevost - this is ready for another review. Thanks for the suggestions, I liked all of them. |
This establishes a connection from USE UI to TACOS, allowing all instances of the application to separate their traffic for analysis within TACOS using a
TACOS_SOURCE
environment variable.The strategy is similar to other integrations, defining a separate route that the UI will query via Hotwire. For now, the response is only an HTML comment, but USE-65 will make that into something real.
The Tacos model added here is similar to - but not identical to - the Tacos model being used in Bento. The two big changes are:
sourceSystem
via an ENV, since we have multiple instances of this application and only one Bento.Developer
Ticket: https://mitlibraries.atlassian.net/browse/USE-66
Accessibility
To be clear, because the only response from TACOS for now is meant to be invisible to the user, I've not checked any a11y considerations to that panel appearing.
New ENV
The ENV is defined in the PR build, and documented in the README - but I've not yet modified the pipeline. That will come after PR approval.
Approval beyond code review
Additional context needed to review
The PR build associated with this branch has been configured to communicate with the staging TACOS, if you want to poke around a bit.
Code Reviewer
Code
added technical debt.
Documentation
(not just this pull request message).
Testing