-
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
Replace TaskList with jsonapi #1187
Conversation
config/config.exs
Outdated
@@ -84,6 +84,9 @@ config :sentry, | |||
|
|||
config :code_corps, :processor, CodeCorps.Processor.Async | |||
|
|||
config :jsonapi, | |||
remove_links: 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.
underscore_to_dash
is giving me this error. Perhaps a PR.
** (Protocol.UndefinedError) protocol Enumerable not implemented for #DateTime<2017-11-13 15:38:42Z>. This protocol is implemented for: DBConnection.PrepareStream, DBConnection.Stream,
Date.Range, Ecto.Adapters.SQL.Stream, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, List, Map, MapSet, Postgrex.Stream, Range, Scrivener.Page, Stream, Timex.Interval
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.
Looks like problems with serializing a date. We'll have to look into it. Any open or closed issues related to date serialization?
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.
Narrowing down to which field is creating the problem would likely help. Maybe disable one attribute at a time to see what happens?
has_many :tasks, serializer: CodeCorpsWeb.TaskView, identifiers: :always | ||
def render("show.json-api", %{data: task_list, conn: conn, params: params}) do | ||
__MODULE__.show(task_list, conn, params) | ||
end |
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.
Would rather just call the show/index action directly from the controller, but was getting failing controller tests around expected connection to have a response but no response was set/sent. Please verify that you assign to "conn" after a request
. Will have to investigate more.
@@ -7,7 +7,7 @@ defmodule CodeCorpsWeb.TaskListViewTest do | |||
task = insert(:task, order: 1000, task_list: task_list) | |||
|
|||
task_list = CodeCorpsWeb.TaskListController.preload(task_list) | |||
rendered_json = render(CodeCorpsWeb.TaskListView, "show.json-api", data: task_list) | |||
rendered_json = render(CodeCorpsWeb.TaskListView, "show.json-api", %{data: task_list, conn: %Plug.Conn{}, params: task_list.id}) | |||
|
|||
expected_json = %{ |
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.
@begedin this is failing. I returns a map with atom keys. Should the json be a map with string keys or doesn't it matter?
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.
We have keys such as "pull-requests"
, so I'm not sure they can be atoms. Is this configurable in jsonapi?
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.
I see you said underscore_to_dash: true,
is giving you errors above. We need that to. Our Ember client is expecting dashes.
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.
These comments are pending for a couple of days now. Not sure how I missed it. Sorry about that. I hope they help.
@@ -7,7 +7,7 @@ defmodule CodeCorpsWeb.TaskListViewTest do | |||
task = insert(:task, order: 1000, task_list: task_list) | |||
|
|||
task_list = CodeCorpsWeb.TaskListController.preload(task_list) | |||
rendered_json = render(CodeCorpsWeb.TaskListView, "show.json-api", data: task_list) | |||
rendered_json = render(CodeCorpsWeb.TaskListView, "show.json-api", %{data: task_list, conn: %Plug.Conn{}, params: task_list.id}) | |||
|
|||
expected_json = %{ |
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.
We have keys such as "pull-requests"
, so I'm not sure they can be atoms. Is this configurable in jsonapi?
@@ -7,7 +7,7 @@ defmodule CodeCorpsWeb.TaskListViewTest do | |||
task = insert(:task, order: 1000, task_list: task_list) | |||
|
|||
task_list = CodeCorpsWeb.TaskListController.preload(task_list) | |||
rendered_json = render(CodeCorpsWeb.TaskListView, "show.json-api", data: task_list) | |||
rendered_json = render(CodeCorpsWeb.TaskListView, "show.json-api", %{data: task_list, conn: %Plug.Conn{}, params: task_list.id}) | |||
|
|||
expected_json = %{ |
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.
I see you said underscore_to_dash: true,
is giving you errors above. We need that to. Our Ember client is expecting dashes.
config/config.exs
Outdated
@@ -84,6 +84,9 @@ config :sentry, | |||
|
|||
config :code_corps, :processor, CodeCorps.Processor.Async | |||
|
|||
config :jsonapi, | |||
remove_links: 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.
Looks like problems with serializing a date. We'll have to look into it. Any open or closed issues related to date serialization?
config/config.exs
Outdated
@@ -84,6 +84,9 @@ config :sentry, | |||
|
|||
config :code_corps, :processor, CodeCorps.Processor.Async | |||
|
|||
config :jsonapi, | |||
remove_links: 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.
Narrowing down to which field is creating the problem would likely help. Maybe disable one attribute at a time to see what happens?
ac30789
to
5dd7826
Compare
@begedin @joshsmith So I got a good working version for task_list. However, it kind of creates a snowball effect b/c ProjectView / TaskView needs to be changed. Then those relationship views need to be updated. I wanted to know your thoughts on tackling this. It's a big refactor so just wanted to ping you guys to make sure its a ok. I can try to get it done today... |
@joshsmith So here is where I am at. I separated out the project and task views to their own files specific for the task_list view so to avoid a huge refactor. These relationships are now The only piece of housekeeping is ensuring the custom attribute methods that are defined on the view can be included in the attributes...which may be a PR to jsonapi. |
@begedin @joshsmith Just to add to what the goal is...It would be great to use the |
Going to close this in favor of #1302 for right now. |
This is a WIP. A few PR's to jsonapi may be in order. Need to investigate more.
Progress on: #1139