Skip to content

Commit 7ea90d3

Browse files
authored
Merge pull request #1351 from MITLibraries/tco-66-hints-to-tacos
Replace Hints with Suggested Resources
2 parents 29fd71f + 5464e64 commit 7ea90d3

35 files changed

+292
-1959
lines changed

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ group :production do
3333
end
3434

3535
group :development, :test do
36-
gem 'pry-rails'
36+
gem 'debug', platforms: %i[mri mingw x64_mingw]
3737
gem 'sqlite3'
3838
end
3939

@@ -49,6 +49,7 @@ group :development do
4949
end
5050

5151
group :test do
52+
gem 'climate_control'
5253
gem 'minitest-rails'
5354
gem 'mocha', require: false
5455
gem 'simplecov', require: false

Gemfile.lock

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ GEM
104104
bootsnap (1.18.3)
105105
msgpack (~> 1.2)
106106
builder (3.3.0)
107+
climate_control (1.2.0)
107108
coderay (1.1.3)
108109
concurrent-ruby (1.3.4)
109110
crack (1.0.0)
@@ -112,6 +113,9 @@ GEM
112113
crass (1.0.6)
113114
dalli (3.2.8)
114115
date (3.3.4)
116+
debug (1.9.2)
117+
irb (~> 1.10)
118+
reline (>= 0.3.8)
115119
debug_inspector (1.2.0)
116120
declarative (0.0.20)
117121
docile (1.4.0)
@@ -178,7 +182,11 @@ GEM
178182
httpclient (2.8.3)
179183
i18n (1.14.5)
180184
concurrent-ruby (~> 1.0)
185+
io-console (0.7.2)
181186
ipaddr_range_set (1.0.0)
187+
irb (1.14.0)
188+
rdoc (>= 4.0.0)
189+
reline (>= 0.4.2)
182190
jquery-rails (4.6.0)
183191
rails-dom-testing (>= 1, < 3)
184192
railties (>= 4.2.0)
@@ -240,11 +248,8 @@ GEM
240248
ast (~> 2.4.1)
241249
racc
242250
pg (1.5.6)
243-
pry (0.14.2)
244-
coderay (~> 1.1)
245-
method_source (~> 1.0)
246-
pry-rails (0.3.11)
247-
pry (>= 0.13.0)
251+
psych (5.1.2)
252+
stringio
248253
public_suffix (6.0.0)
249254
puma (6.4.2)
250255
nio4r (~> 2.0)
@@ -287,7 +292,11 @@ GEM
287292
rb-fsevent (0.11.2)
288293
rb-inotify (0.11.1)
289294
ffi (~> 1.0)
295+
rdoc (6.7.0)
296+
psych (>= 4.0.0)
290297
regexp_parser (2.9.2)
298+
reline (0.5.9)
299+
io-console (~> 0.5)
291300
representable (3.2.0)
292301
declarative (< 0.1.0)
293302
trailblazer-option (>= 0.1.1, < 0.2.0)
@@ -359,6 +368,7 @@ GEM
359368
mini_portile2 (~> 2.8.0)
360369
statsd-ruby (1.5.0)
361370
stringex (2.8.6)
371+
stringio (3.1.1)
362372
strscan (3.1.0)
363373
terminal-table (3.0.2)
364374
unicode-display_width (>= 1.1.1, < 3)
@@ -398,7 +408,9 @@ DEPENDENCIES
398408
better_errors
399409
binding_of_caller
400410
bootsnap
411+
climate_control
401412
dalli
413+
debug
402414
dotenv-rails
403415
flipflop
404416
google-api-client
@@ -417,7 +429,6 @@ DEPENDENCIES
417429
net-smtp
418430
nokogiri
419431
pg
420-
pry-rails
421432
puma
422433
rack-attack
423434
rails (~> 7.0.0)

README.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,6 @@ for some of these APIs (see below).
1515

1616
![alt text](docs/charts/bento_overview.png "Bento system overview chart")
1717

18-
## Loading Hints
19-
20-
Tasks exist to reload hints from supported sources. To reload custom hints in a development environment:
21-
22-
```
23-
heroku local:run bin/rails reloadhints:custom[https://www.dropbox.com/blah/blah]
24-
```
25-
26-
To reload custom hints in a heroku environment:
27-
28-
```
29-
heroku run bin/rails reloadhints:custom['https://www.dropbox.com/blah/blah'] --app your-appname-staging
30-
```
31-
32-
Depending on your shell, you may need single-quotes around the URL.
33-
34-
This expects to find a world-readable CSV file at the Dropbox location. Instructions for generating that file are in the
35-
Google sheet where we gather custom hint metadata.
36-
3718
## Required Environment Variables
3819

3920
- `ALMA_OPENURL`: base URL for Alma openurls found in CDI records.
@@ -72,6 +53,7 @@ to construct thumbnail URLs.
7253
- Hints will only be displayed to the user if they are in `HINT_SOURCES`.
7354
- `LOG_LEVEL`: set log level for development, default is `:debug`
7455
- `LOG_LIKE_PROD`: uses prod-like logging in development if set
56+
- `ORIGINS`: sets origins for CORS (currently used only for TACOS API calls).
7557
- `PLATFORM_NAME`: The value set is added to the header after the MIT Libraries logo. The logic and CSS for this comes from our theme gem.
7658
- `PRIMO_TIMEOUT`: value to override the 6 second default for Primo timeout.
7759
- `REQUESTS_PER_PERIOD`: number of requests per time period we allow from a
@@ -82,7 +64,8 @@ to construct thumbnail URLs.
8264
- `RESULTS_PER_BOX`: defaults to 3
8365
- `SENTRY_DSN`: logs exceptions to Sentry
8466
- `SENTRY_ENV`: Sentry environment for the application. Defaults to 'unknown' if unset.
85-
- `TACOS_URL`: The GraphQL endpoint for the [TACOS](https://github.com/mitlibraries/tacos/) application.
67+
- `TACOS_URL`: The GraphQL endpoint for the [TACOS API](https://github.com/mitlibraries/tacos/). When set, the
68+
application will log search terms to TACOS and return suggested resources detected in search terms.
8669
- `TIMDEX_TIMEOUT`: value to override the 6 second default for TIMDEX timeout.
8770

8871
### NPS Survey Environment Variables (optional)

app/assets/stylesheets/_hint.scss renamed to app/assets/stylesheets/_suggested_resources.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
.hint-box {
2+
.suggested-resources-box {
33
position: relative;
44
margin: 1.5% 0;
55
box-shadow: 0px 1px 3px rgba($blue, .5);

app/assets/stylesheets/application.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
@import "_bento";
77
@import "_search";
88
@import "_results";
9-
@import "_hint";
9+
@import "_suggested_resources";
1010
@import "_survey";
1111
@import "_print";

app/controllers/hint_controller.rb

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class TacosController < ApplicationController
2+
# Calls TACOS API to log search terms and return suggested resources.
3+
def suggested_resources
4+
# Do nothing unless all required env is set and a query param exists.
5+
return if ENV.fetch('TACOS_URL', nil).blank? || ENV.fetch('ORIGINS', nil).blank?
6+
return if params[:q].blank?
7+
8+
response = Tacos.call(params[:q])
9+
@suggested_resources = response['data']['logSearchEvent']['detectors']['suggestedResources']
10+
render layout: false
11+
end
12+
end

app/helpers/hint_helper.rb

Lines changed: 0 additions & 20 deletions
This file was deleted.

app/models/custom_hint.rb

Lines changed: 0 additions & 56 deletions
This file was deleted.

app/models/hint.rb

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)