The first piece of the puzzle in teaching Rosalind how to talk to Gravity's filter/artworks endpoint is to add this service class, that can take filter params, fire off the query and return the response.
(This basically clones the existing ArtworkSearchService class, but points to Gravity instead of Elasticsearch)
Still to come in future PRs:
wiring this up to the Rails controllers
wiring the backend up to the frontend
adding support for a few fields such as creation date, and published (unless we decide to drop those)
Sample console usage for now:
foreman run bundle exec rails console # assuming a proper .env pointing to Gravity
Then:
# a simple query
FilteredArtworkSearchService.call(for_sale: true) # => { hits: […] }
# a compound query, equivalent to the content in
# https://www.artsy.net/collection/barbara-hepworth-wood-sculpture
FilteredArtworkSearchService.call(
gene_ids: ["4d90d18edcdd5f44a5000013"],
artist_ids: ["4f0648328501fa10ca0001ad"],
keyword: "wood",
sort: "-decayed_merch"
)
# works with slugs as well:
FilteredArtworkSearchService.call(
gene_ids: ["sculpture"],
artist_ids: ["barbara-hepworth"],
keyword: "wood",
sort: "-decayed_merch"
)
https://artsyproduct.atlassian.net/browse/FX-4109
The first piece of the puzzle in teaching Rosalind how to talk to Gravity's
filter/artworks
endpoint is to add this service class, that can take filter params, fire off the query and return the response.(This basically clones the existing ArtworkSearchService class, but points to Gravity instead of Elasticsearch)
Still to come in future PRs:
Sample console usage for now:
Then: