-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include tasks in view #1302
base: develop
Are you sure you want to change the base?
include tasks in view #1302
Conversation
3badf8a
to
646b4c3
Compare
@@ -7,5 +7,5 @@ defmodule CodeCorpsWeb.TaskListView do | |||
|
|||
has_one :project, type: "project", field: :project_id | |||
|
|||
has_many :tasks, serializer: CodeCorpsWeb.TaskView, identifiers: :always | |||
has_many :tasks, serializer: CodeCorpsWeb.TaskIncludedView, identifiers: :always, include: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better to call this TaskSlimView.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a bad idea. Ideally, I would love if we could just specify what to include and where.
Possibly even the Ember client would do it, so we don't have to worry about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kind of like graphql? I would love that. I worked on a project and eventually there was 5 different views for the same resource, each giving you a different subset of data. It was slightly hard to manage.
We implemented the request on the ember side, but eventually the logic got complex and the various views were easier to manage.
has_one :github_repo, type: "github-repo", field: :github_repo_id | ||
has_one :user, serializer: CodeCorpsWeb.UserIncludedView, include: true | ||
has_one :user_task, serializer: CodeCorpsWeb.UserTaskView, include: true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This task now includes all relevant relationships I believe that are needed for the task index route.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshsmith @snewcomer and I talked about this in Slack for a bit, but I'm not sure how up to date you are.
Right now, our task list on ember is effectively doing a manual include of a lot of stuff, firing off a bunch of requests before rendering the page.
We're acting as if it's all async, but really, almost none of it is.
This would do on the API what Ember is trying to do on its own - include everything it needs and get it as a single request.
How do you feel about it?
@@ -7,5 +7,5 @@ defmodule CodeCorpsWeb.TaskListView do | |||
|
|||
has_one :project, type: "project", field: :project_id | |||
|
|||
has_many :tasks, serializer: CodeCorpsWeb.TaskView, identifiers: :always | |||
has_many :tasks, serializer: CodeCorpsWeb.TaskIncludedView, identifiers: :always, include: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a bad idea. Ideally, I would love if we could just specify what to include and where.
Possibly even the Ember client would do it, so we don't have to worry about this.
@begedin is this something we can talk about sync some soon? I'd like to actually step through this a little more explicitly to wrap my head around it. |
@joshsmith Posted a comment which we could conver into an issue at #1349 (comment) but I would agree that this is wort standup time. |
@begedin wasn't our conclusion that this is necessary to do, we just need clarity on what the client is going to need so we can design our API more intentionally? |
In fact, JSON API provides mechanisms to do exactly this: render subsets of data based on what the client requests. |
Including conversation parts in conversation is easier to merge ahead of time, since it doesn't alter much in our architecture, so I would say #1349 is good to go for now, as something we do before adding support for explicit includes. However, this one is harder to decide on, since it involves adding new subtypes of views, which is an architecture change. It still seems to be an improvement in performance, but I'm not sure what else it entails. |
4290c33
to
4f41648
Compare
e075407
to
6d6cc63
Compare
WIP
So this is a first stab at including tasks in the task_list view and would remove the need for this line
taskLists.forEach((taskList) => get(taskList, 'tasks').reload());
in the tasks index route.A couple of notes:
Progress on: #1156