artsy / rosalind

Admin app for batch operations on genomes
https://artsy.github.io/blog/2019/05/09/rosalind/
MIT License
5 stars 8 forks source link

feat(filter artworks): add a service that queries Gravity filter/artworks #669

Closed anandaroop closed 2 years ago

anandaroop commented 2 years ago

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:


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"
)