Skip to content

Commit a4aca6c

Browse files
authored
Merge pull request #111 from CDRH/dev
v1.0.2
2 parents 184b08c + ee875d6 commit a4aca6c

10 files changed

Lines changed: 596 additions & 141 deletions

File tree

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ruby-2.5.3
1+
ruby-2.6.6

CHANGELOG.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Apium Changelog
2+
3+
All notable changes to Apium will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic
7+
Versioning](https://semver.org/spec/v2.0.0.html).
8+
9+
<!-- Template - Please preserve this order of sections
10+
## [Unreleased] - Brief description
11+
[Unreleased]: https://github.com/CDRH/api/compare/v#.#.#...dev
12+
13+
### Fixed
14+
15+
### Added
16+
17+
### Changed
18+
19+
### Removed
20+
21+
### Migration
22+
23+
### Deprecated
24+
25+
### Contributors
26+
-->
27+
28+
## [v1.0.2](https://github.com/CDRH/api/compare/v1.0.1...v1.0.2) - escapes and sorting
29+
30+
### Fixed
31+
- question mark and asterisk behavior in queries
32+
- order of expected, actual in tests
33+
- sort behavior for relevancy
34+
35+
### Added
36+
- support for multivalued and nested field sorting
37+
- documentation moved back into apium from henbit location in order to version it with software
38+
39+
### Changed
40+
- ruby, rails, and other gem versions
41+
42+
## [v1.0.1](https://github.com/CDRH/api/compare/v1.00...v1.0.1) - version 1.0.1
43+
44+
### Changed
45+
- ruby, rails, and other gem versions
46+
- version moved to initializer
47+
48+
## [v1.0.0](https://github.com/CDRH/api/tree/v1.0.0) - Initial Launch

Gemfile.lock

Lines changed: 77 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,149 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actioncable (5.2.1)
5-
actionpack (= 5.2.1)
4+
actioncable (5.2.4.3)
5+
actionpack (= 5.2.4.3)
66
nio4r (~> 2.0)
77
websocket-driver (>= 0.6.1)
8-
actionmailer (5.2.1)
9-
actionpack (= 5.2.1)
10-
actionview (= 5.2.1)
11-
activejob (= 5.2.1)
8+
actionmailer (5.2.4.3)
9+
actionpack (= 5.2.4.3)
10+
actionview (= 5.2.4.3)
11+
activejob (= 5.2.4.3)
1212
mail (~> 2.5, >= 2.5.4)
1313
rails-dom-testing (~> 2.0)
14-
actionpack (5.2.1)
15-
actionview (= 5.2.1)
16-
activesupport (= 5.2.1)
17-
rack (~> 2.0)
14+
actionpack (5.2.4.3)
15+
actionview (= 5.2.4.3)
16+
activesupport (= 5.2.4.3)
17+
rack (~> 2.0, >= 2.0.8)
1818
rack-test (>= 0.6.3)
1919
rails-dom-testing (~> 2.0)
2020
rails-html-sanitizer (~> 1.0, >= 1.0.2)
21-
actionview (5.2.1)
22-
activesupport (= 5.2.1)
21+
actionview (5.2.4.3)
22+
activesupport (= 5.2.4.3)
2323
builder (~> 3.1)
2424
erubi (~> 1.4)
2525
rails-dom-testing (~> 2.0)
2626
rails-html-sanitizer (~> 1.0, >= 1.0.3)
27-
activejob (5.2.1)
28-
activesupport (= 5.2.1)
27+
activejob (5.2.4.3)
28+
activesupport (= 5.2.4.3)
2929
globalid (>= 0.3.6)
30-
activemodel (5.2.1)
31-
activesupport (= 5.2.1)
32-
activerecord (5.2.1)
33-
activemodel (= 5.2.1)
34-
activesupport (= 5.2.1)
30+
activemodel (5.2.4.3)
31+
activesupport (= 5.2.4.3)
32+
activerecord (5.2.4.3)
33+
activemodel (= 5.2.4.3)
34+
activesupport (= 5.2.4.3)
3535
arel (>= 9.0)
36-
activestorage (5.2.1)
37-
actionpack (= 5.2.1)
38-
activerecord (= 5.2.1)
36+
activestorage (5.2.4.3)
37+
actionpack (= 5.2.4.3)
38+
activerecord (= 5.2.4.3)
3939
marcel (~> 0.3.1)
40-
activesupport (5.2.1)
40+
activesupport (5.2.4.3)
4141
concurrent-ruby (~> 1.0, >= 1.0.2)
4242
i18n (>= 0.7, < 2)
4343
minitest (~> 5.1)
4444
tzinfo (~> 1.1)
4545
arel (9.0.0)
46-
bootsnap (1.3.2)
46+
bootsnap (1.4.6)
4747
msgpack (~> 1.0)
48-
builder (3.2.3)
49-
byebug (10.0.2)
50-
concurrent-ruby (1.1.3)
51-
crass (1.0.4)
52-
domain_name (0.5.20180417)
48+
builder (3.2.4)
49+
byebug (11.1.3)
50+
concurrent-ruby (1.1.6)
51+
crass (1.0.6)
52+
domain_name (0.5.20190701)
5353
unf (>= 0.0.5, < 1.0.0)
54-
erubi (1.7.1)
55-
ffi (1.9.25)
56-
globalid (0.4.1)
54+
erubi (1.9.0)
55+
ffi (1.13.1)
56+
globalid (0.4.2)
5757
activesupport (>= 4.2.0)
5858
http-accept (1.7.0)
5959
http-cookie (1.0.3)
6060
domain_name (~> 0.5)
61-
i18n (1.1.1)
61+
i18n (1.8.3)
6262
concurrent-ruby (~> 1.0)
6363
listen (3.1.5)
6464
rb-fsevent (~> 0.9, >= 0.9.4)
6565
rb-inotify (~> 0.9, >= 0.9.7)
6666
ruby_dep (~> 1.2)
67-
loofah (2.2.3)
67+
loofah (2.6.0)
6868
crass (~> 1.0.2)
6969
nokogiri (>= 1.5.9)
7070
mail (2.7.1)
7171
mini_mime (>= 0.1.1)
7272
marcel (0.3.3)
7373
mimemagic (~> 0.3.2)
74-
method_source (0.9.2)
75-
mime-types (3.2.2)
74+
method_source (1.0.0)
75+
mime-types (3.3.1)
7676
mime-types-data (~> 3.2015)
77-
mime-types-data (3.2018.0812)
78-
mimemagic (0.3.2)
79-
mini_mime (1.0.1)
80-
mini_portile2 (2.3.0)
81-
minitest (5.11.3)
82-
msgpack (1.2.4)
77+
mime-types-data (3.2020.0512)
78+
mimemagic (0.3.5)
79+
mini_mime (1.0.2)
80+
mini_portile2 (2.4.0)
81+
minitest (5.14.1)
82+
msgpack (1.3.3)
8383
netrc (0.11.0)
84-
nio4r (2.3.1)
85-
nokogiri (1.8.5)
86-
mini_portile2 (~> 2.3.0)
87-
puma (3.12.0)
88-
rack (2.0.6)
84+
nio4r (2.5.2)
85+
nokogiri (1.10.10)
86+
mini_portile2 (~> 2.4.0)
87+
puma (3.12.6)
88+
rack (2.2.3)
8989
rack-test (1.1.0)
9090
rack (>= 1.0, < 3)
91-
rails (5.2.1)
92-
actioncable (= 5.2.1)
93-
actionmailer (= 5.2.1)
94-
actionpack (= 5.2.1)
95-
actionview (= 5.2.1)
96-
activejob (= 5.2.1)
97-
activemodel (= 5.2.1)
98-
activerecord (= 5.2.1)
99-
activestorage (= 5.2.1)
100-
activesupport (= 5.2.1)
91+
rails (5.2.4.3)
92+
actioncable (= 5.2.4.3)
93+
actionmailer (= 5.2.4.3)
94+
actionpack (= 5.2.4.3)
95+
actionview (= 5.2.4.3)
96+
activejob (= 5.2.4.3)
97+
activemodel (= 5.2.4.3)
98+
activerecord (= 5.2.4.3)
99+
activestorage (= 5.2.4.3)
100+
activesupport (= 5.2.4.3)
101101
bundler (>= 1.3.0)
102-
railties (= 5.2.1)
102+
railties (= 5.2.4.3)
103103
sprockets-rails (>= 2.0.0)
104104
rails-dom-testing (2.0.3)
105105
activesupport (>= 4.2.0)
106106
nokogiri (>= 1.6)
107-
rails-html-sanitizer (1.0.4)
108-
loofah (~> 2.2, >= 2.2.2)
109-
railties (5.2.1)
110-
actionpack (= 5.2.1)
111-
activesupport (= 5.2.1)
107+
rails-html-sanitizer (1.3.0)
108+
loofah (~> 2.3)
109+
railties (5.2.4.3)
110+
actionpack (= 5.2.4.3)
111+
activesupport (= 5.2.4.3)
112112
method_source
113113
rake (>= 0.8.7)
114114
thor (>= 0.19.0, < 2.0)
115-
rake (12.3.1)
116-
rb-fsevent (0.10.3)
117-
rb-inotify (0.9.10)
118-
ffi (>= 0.5.0, < 2)
119-
rest-client (2.1.0.rc1)
115+
rake (13.0.1)
116+
rb-fsevent (0.10.4)
117+
rb-inotify (0.10.1)
118+
ffi (~> 1.0)
119+
rest-client (2.1.0)
120120
http-accept (>= 1.7.0, < 2.0)
121121
http-cookie (>= 1.0.2, < 2.0)
122122
mime-types (>= 1.16, < 4.0)
123123
netrc (~> 0.8)
124124
ruby_dep (1.5.0)
125-
spring (2.0.2)
126-
activesupport (>= 4.2)
125+
spring (2.1.0)
127126
spring-watcher-listen (2.0.1)
128127
listen (>= 2.7, < 4.0)
129128
spring (>= 1.2, < 3.0)
130-
sprockets (3.7.2)
129+
sprockets (4.0.2)
131130
concurrent-ruby (~> 1.0)
132131
rack (> 1, < 3)
133132
sprockets-rails (3.2.1)
134133
actionpack (>= 4.0)
135134
activesupport (>= 4.0)
136135
sprockets (>= 3.0.0)
137-
sqlite3 (1.3.13)
138-
thor (0.20.3)
136+
sqlite3 (1.4.2)
137+
thor (1.0.1)
139138
thread_safe (0.3.6)
140-
tzinfo (1.2.5)
139+
tzinfo (1.2.7)
141140
thread_safe (~> 0.1)
142141
unf (0.1.4)
143142
unf_ext
144-
unf_ext (0.0.7.5)
145-
websocket-driver (0.7.0)
143+
unf_ext (0.0.7.7)
144+
websocket-driver (0.7.3)
146145
websocket-extensions (>= 0.1.0)
147-
websocket-extensions (0.1.3)
146+
websocket-extensions (0.1.5)
148147

149148
PLATFORMS
150149
ruby
@@ -162,4 +161,4 @@ DEPENDENCIES
162161
tzinfo-data
163162

164163
BUNDLED WITH
165-
1.16.2
164+
2.1.4

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# Henbit
1+
# Apium
22

3-
Henbit is an API to access all public Center for Digital Research in the Humanities resources. It is also an invasive weed in Nebraska.
3+
Apium is an API to access all public Center for Digital Research in the Humanities resources. It is also an invasive weed in Nebraska.
44

5-
**Henbit Documentation can be found [in our documentation repository](https://github.com/CDRH/sneezewort/blob/master/docs/api/README.md)**
6-
7-
**Documentation for entire publishing system can be found here: ([https://github.com/CDRH/sneezewort](https://github.com/CDRH/sneezewort))**
5+
**[Apium Documentation](docs/README.md)**

app/services/search_item_req.rb

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ def self.escape_chars(query)
5959
# for the lucene escaping code below
6060
# Note: removed () and : from list, because escaping
6161
# those characters interfered with elasticsearch multifield searching
62-
escaped_characters = Regexp.escape('\\+-&|!{}[]^~*?\/')
62+
# Also removed * and ? from the list because escaping those
63+
# characters meant queries with uncertainty couldn't be done
64+
escaped_characters = Regexp.escape('\\+-&|!{}[]^~\/')
6365
query.gsub(/([#{escaped_characters}])/, '\\\\\1')
6466
end
6567

@@ -234,7 +236,7 @@ def sort
234236
sort_param = nil
235237
if @params["sort"].blank?
236238
if @params["q"].present?
237-
sort_param = ["_score|desc"]
239+
sort_param = ["_score"]
238240
else
239241
sort_param = [SETTINGS["sort_fl"]]
240242
end
@@ -244,11 +246,33 @@ def sort
244246

245247
sort_param.each do |sort|
246248
term, dir = sort.split(@@filter_separator)
247-
term = "_score" if term == "relevancy"
248-
if dir.blank?
249-
dir = term == "relevancy" ? "desc" : "asc"
249+
if term == "relevancy" || term == "_score"
250+
sort_obj << "_score"
251+
else
252+
dir = "asc" if dir.blank?
253+
# instructions for multivalued field sorting
254+
# ex: desc [D], [A, F] -> [A, F], [D] because A is max from set
255+
mode = dir == "desc" ? "max" : "min"
256+
# default to sorting missing values last, this may
257+
# be added as a configurable parameter later
258+
missing = "_last"
259+
260+
sort_setting = {
261+
term => {
262+
"order" => dir,
263+
"mode" => mode,
264+
"missing" => missing
265+
}
266+
}
267+
# nested fields require different sorting setup
268+
# note: does not support nested fields inside of nested fields
269+
if term.include?(".")
270+
path = term.split(".").first
271+
sort_setting[term]["nested"] = { "path" => path }
272+
end
273+
sort_obj << sort_setting
250274
end
251-
sort_obj << { term => dir }
275+
252276
end
253277

254278
return sort_obj

config/application.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ class Application < Rails::Application
3232
# Middleware like session, flash, cookies can be added back manually.
3333
# Skip views, helpers and assets when generating a new resource.
3434
config.api_only = true
35+
36+
# sets to avoid deprecation warning in terminal
37+
Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
3538
end
3639
end

config/environments/development.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,15 @@
5151
# Use an evented file watcher to asynchronously detect changes in source code,
5252
# routes, locales, etc. This feature depends on the listen gem.
5353
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
54+
55+
56+
57+
# LOCAL
58+
# Custom dev env logger to empty log more frequently
59+
config.logger = ActiveSupport::TaggedLogging.new(
60+
ActiveSupport::Logger.new(File.join(Rails.root.to_s, "log", "development.log"),
61+
# Keep one old log file, rotate after size reaches 32 MB
62+
1, 32 * 1024 * 1024
63+
)
64+
)
5465
end

config/initializers/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Api
22
class Application < Rails::Application
3-
VERSION = "1.0.1"
3+
VERSION = "1.0.2"
44
end
55
end

0 commit comments

Comments
 (0)