JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Sort methods not being called

Open
#816 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2.3k
Forks
546
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm running off of master (for the caching feature), and the sort/order methods (self.sortable_fields, self.default_sort, and self.apply_sort) are not being called in the resource.

This method is called when I use 0.7.0, but not on master:

class SomeResource < JSONAPI::Resource

  def self.apply_sort(records, order_options, context = {})
    throw records
    records = records.order(id: :desc)
    super(records, order_options, context)
  end
end

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Compare the sorting implementation on master with version 0.7.0, focusing on the resource methods self.sortable_fields, self.default_sort, and self.apply_sort. Reproduce the issue with the SomeResource example and confirm that the sort methods are invoked on master and apply_sort can order records as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.