Skip to content

Commit

Permalink
Merge pull request #111 from CDRH/dev
Browse files Browse the repository at this point in the history
v1.0.2
  • Loading branch information
techgique authored Jul 10, 2020
2 parents 184b08c + ee875d6 commit a4aca6c
Show file tree
Hide file tree
Showing 10 changed files with 596 additions and 141 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.5.3
ruby-2.6.6
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Apium Changelog

All notable changes to Apium will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html).

<!-- Template - Please preserve this order of sections
## [Unreleased] - Brief description
[Unreleased]: https://github.com/CDRH/api/compare/v#.#.#...dev
### Fixed
### Added
### Changed
### Removed
### Migration
### Deprecated
### Contributors
-->

## [v1.0.2](https://github.com/CDRH/api/compare/v1.0.1...v1.0.2) - escapes and sorting

### Fixed
- question mark and asterisk behavior in queries
- order of expected, actual in tests
- sort behavior for relevancy

### Added
- support for multivalued and nested field sorting
- documentation moved back into apium from henbit location in order to version it with software

### Changed
- ruby, rails, and other gem versions

## [v1.0.1](https://github.com/CDRH/api/compare/v1.00...v1.0.1) - version 1.0.1

### Changed
- ruby, rails, and other gem versions
- version moved to initializer

## [v1.0.0](https://github.com/CDRH/api/tree/v1.0.0) - Initial Launch
155 changes: 77 additions & 78 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,150 +1,149 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.1)
actionpack (= 5.2.1)
actioncable (5.2.4.3)
actionpack (= 5.2.4.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.1)
actionpack (= 5.2.1)
actionview (= 5.2.1)
activejob (= 5.2.1)
actionmailer (5.2.4.3)
actionpack (= 5.2.4.3)
actionview (= 5.2.4.3)
activejob (= 5.2.4.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.1)
actionview (= 5.2.1)
activesupport (= 5.2.1)
rack (~> 2.0)
actionpack (5.2.4.3)
actionview (= 5.2.4.3)
activesupport (= 5.2.4.3)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.1)
activesupport (= 5.2.1)
actionview (5.2.4.3)
activesupport (= 5.2.4.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.1)
activesupport (= 5.2.1)
activejob (5.2.4.3)
activesupport (= 5.2.4.3)
globalid (>= 0.3.6)
activemodel (5.2.1)
activesupport (= 5.2.1)
activerecord (5.2.1)
activemodel (= 5.2.1)
activesupport (= 5.2.1)
activemodel (5.2.4.3)
activesupport (= 5.2.4.3)
activerecord (5.2.4.3)
activemodel (= 5.2.4.3)
activesupport (= 5.2.4.3)
arel (>= 9.0)
activestorage (5.2.1)
actionpack (= 5.2.1)
activerecord (= 5.2.1)
activestorage (5.2.4.3)
actionpack (= 5.2.4.3)
activerecord (= 5.2.4.3)
marcel (~> 0.3.1)
activesupport (5.2.1)
activesupport (5.2.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (9.0.0)
bootsnap (1.3.2)
bootsnap (1.4.6)
msgpack (~> 1.0)
builder (3.2.3)
byebug (10.0.2)
concurrent-ruby (1.1.3)
crass (1.0.4)
domain_name (0.5.20180417)
builder (3.2.4)
byebug (11.1.3)
concurrent-ruby (1.1.6)
crass (1.0.6)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
erubi (1.7.1)
ffi (1.9.25)
globalid (0.4.1)
erubi (1.9.0)
ffi (1.13.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
http-accept (1.7.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.1.1)
i18n (1.8.3)
concurrent-ruby (~> 1.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.2.3)
loofah (2.6.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mime-types (3.2.2)
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mimemagic (0.3.2)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
minitest (5.11.3)
msgpack (1.2.4)
mime-types-data (3.2020.0512)
mimemagic (0.3.5)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.1)
msgpack (1.3.3)
netrc (0.11.0)
nio4r (2.3.1)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
puma (3.12.0)
rack (2.0.6)
nio4r (2.5.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
puma (3.12.6)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.1)
actioncable (= 5.2.1)
actionmailer (= 5.2.1)
actionpack (= 5.2.1)
actionview (= 5.2.1)
activejob (= 5.2.1)
activemodel (= 5.2.1)
activerecord (= 5.2.1)
activestorage (= 5.2.1)
activesupport (= 5.2.1)
rails (5.2.4.3)
actioncable (= 5.2.4.3)
actionmailer (= 5.2.4.3)
actionpack (= 5.2.4.3)
actionview (= 5.2.4.3)
activejob (= 5.2.4.3)
activemodel (= 5.2.4.3)
activerecord (= 5.2.4.3)
activestorage (= 5.2.4.3)
activesupport (= 5.2.4.3)
bundler (>= 1.3.0)
railties (= 5.2.1)
railties (= 5.2.4.3)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.1)
actionpack (= 5.2.1)
activesupport (= 5.2.1)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.2.4.3)
actionpack (= 5.2.4.3)
activesupport (= 5.2.4.3)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rake (12.3.1)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rest-client (2.1.0.rc1)
rake (13.0.1)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
ruby_dep (1.5.0)
spring (2.0.2)
activesupport (>= 4.2)
spring (2.1.0)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (3.7.2)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (0.20.3)
sqlite3 (1.4.2)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.5)
tzinfo (1.2.7)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
websocket-driver (0.7.0)
unf_ext (0.0.7.7)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
websocket-extensions (0.1.5)

PLATFORMS
ruby
Expand All @@ -162,4 +161,4 @@ DEPENDENCIES
tzinfo-data

BUNDLED WITH
1.16.2
2.1.4
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Henbit
# Apium

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

**Henbit Documentation can be found [in our documentation repository](https://github.com/CDRH/sneezewort/blob/master/docs/api/README.md)**

**Documentation for entire publishing system can be found here: ([https://github.com/CDRH/sneezewort](https://github.com/CDRH/sneezewort))**
**[Apium Documentation](docs/README.md)**
36 changes: 30 additions & 6 deletions app/services/search_item_req.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def self.escape_chars(query)
# for the lucene escaping code below
# Note: removed () and : from list, because escaping
# those characters interfered with elasticsearch multifield searching
escaped_characters = Regexp.escape('\\+-&|!{}[]^~*?\/')
# Also removed * and ? from the list because escaping those
# characters meant queries with uncertainty couldn't be done
escaped_characters = Regexp.escape('\\+-&|!{}[]^~\/')
query.gsub(/([#{escaped_characters}])/, '\\\\\1')
end

Expand Down Expand Up @@ -234,7 +236,7 @@ def sort
sort_param = nil
if @params["sort"].blank?
if @params["q"].present?
sort_param = ["_score|desc"]
sort_param = ["_score"]
else
sort_param = [SETTINGS["sort_fl"]]
end
Expand All @@ -244,11 +246,33 @@ def sort

sort_param.each do |sort|
term, dir = sort.split(@@filter_separator)
term = "_score" if term == "relevancy"
if dir.blank?
dir = term == "relevancy" ? "desc" : "asc"
if term == "relevancy" || term == "_score"
sort_obj << "_score"
else
dir = "asc" if dir.blank?
# instructions for multivalued field sorting
# ex: desc [D], [A, F] -> [A, F], [D] because A is max from set
mode = dir == "desc" ? "max" : "min"
# default to sorting missing values last, this may
# be added as a configurable parameter later
missing = "_last"

sort_setting = {
term => {
"order" => dir,
"mode" => mode,
"missing" => missing
}
}
# nested fields require different sorting setup
# note: does not support nested fields inside of nested fields
if term.include?(".")
path = term.split(".").first
sort_setting[term]["nested"] = { "path" => path }
end
sort_obj << sort_setting
end
sort_obj << { term => dir }

end

return sort_obj
Expand Down
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ class Application < Rails::Application
# Middleware like session, flash, cookies can be added back manually.
# Skip views, helpers and assets when generating a new resource.
config.api_only = true

# sets to avoid deprecation warning in terminal
Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
end
end
11 changes: 11 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,15 @@
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker



# LOCAL
# Custom dev env logger to empty log more frequently
config.logger = ActiveSupport::TaggedLogging.new(
ActiveSupport::Logger.new(File.join(Rails.root.to_s, "log", "development.log"),
# Keep one old log file, rotate after size reaches 32 MB
1, 32 * 1024 * 1024
)
)
end
2 changes: 1 addition & 1 deletion config/initializers/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Api
class Application < Rails::Application
VERSION = "1.0.1"
VERSION = "1.0.2"
end
end
Loading

0 comments on commit a4aca6c

Please sign in to comment.