Add a hook for retrieving ActiveRecord fragments for included relationships

オープン
#958 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rails, ruby
領域
api, backend, database

調査の方向性

まず、GET /groups/?include=users がどのように UserResource に到達するかを追跡し、issue に記載されている records と apply_includes のパスを比較します。各関連リソースで apply_includes をオーバーライドせず、モデルごとに個別のクエリを発行することもなく、リソースレベルの 1 つのフックで包含されたリレーションを最適化できれば、作業は完了です。

索引モデルが issue の本文から書いたものです。

説明

For example, if you have a resource UserResource with a method like this

def friends
   @model.friends.size
end

It will load user.friends separately for each model in the list. So you can optimise the query like this:

class self.records
    _model_class.all.includes(:friends)
end

Then when requesting GET /users/ it now works well. However, say if you request something like GET /groups/?include=users, the records method on UserResource is never called, so there is no query optimisation.

Instead of overriding self.apply_includes(records, options = {}) on each resource that has a relationship to UserResource, it would be nice to have a way to do this only once per resource.

@lgebhardt as discussed on Gitter

主要言語
Ruby
スター
2.3k
フォーク
546
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

JSONAPI-Resources/jsonapi-resources のほかの issue

JSONAPI-Resources/jsonapi-resources の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。