-
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
Add pull_requests && done to task_list #1157
Conversation
lib/code_corps/model/task_list.ex
Outdated
@@ -52,7 +56,7 @@ defmodule CodeCorps.TaskList do | |||
|
|||
def create_changeset(struct, params) do | |||
struct | |||
|> cast(params, [:inbox]) | |||
|> cast(params, [:inbox, :done, :pull_requests]) |
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 alpha-order here.
priv/repo/modify_task_list_done.exs
Outdated
Task | ||
|> CodeCorps.Helpers.Query.project_filter(%{project_id: project.id}) | ||
|> Repo.all() | ||
|> Enum.each(&assign_task_to_done(&1, Enum.at(project.task_lists, 3))) |
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.
What's this doing?
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.
Calls assign_task_to_done(&1, 3rd_task_list_in_project)
, which is, I assume, the task list with done: true
. It would, however, be preferable to call update_tasks_to_done/1
with that task list as an argument.
lib/code_corps/model/task_list.ex
Outdated
name: "In Progress", | ||
position: 3 | ||
}, %{ | ||
inbox: false, | ||
done: true, | ||
name: "Done", | ||
position: 4 | ||
} |
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 would probably remove inbox: false
from the others here for consistency.
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 remove all inbox: false
?
priv/repo/modify_task_list_done.exs
Outdated
TaskList.create_changeset(task_list, %{done: true}) | ||
|> Repo.update() | ||
end | ||
defp update_done_column(task_list), do: task_list |
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 is good, but will also need a similar fn for %TaskList{name: "In Progress"}
to make it the pull_requests
list.
priv/repo/modify_task_list_done.exs
Outdated
TaskList | ||
|> Repo.all() | ||
|> Enum.each(&update_pr_column/1) | ||
|
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 could be condensed down to:
TaskList
|> Repo.all()
|> Enum.each(&update_done_column/1)
|> Enum.each(&update_pr_column/1)
I've used the migration script you wrote, Scott, and moved it's behavior into the migrations themselves. I did not get a chance to comment on the issues this PR resolves, so the instructions there do not match what I did, but I really feel this should be our preferable approach to handling migrations. The code that migrates the data uses schema names instead of our schema modules, so it's agnostic to our actual modules and works regardless of what the rest of our code looks like. Due to separate |
da90d36
to
3a48282
Compare
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.
@snewcomer Great work. I made some changes to how migrations are done, worded a couple of your tests differently and cleaned up.
This is about done, so I'm approving your part from my end. @joshsmith can review and approve my part.
test "defaults :pull_requests to 'false'" do | ||
{:ok, record} = | ||
%TaskList{} |> TaskList.changeset(@valid_attrs) |> Repo.insert | ||
assert record.pull_requests == false |
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.
@snewcomer Your assertion here was refute record.pull_requests
, but that one would have passed even if record.pull_requests == nil
, so we want a more explicit one.
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.
🤦♂️
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.
Just adding a blank "request changes" review here, so we don't accidentally merge before @joshsmith reviews.
c714aa5
to
03a06f0
Compare
where: not is_nil(gi.github_pull_request_id), | ||
update: [set: [task_list_id: ^pr_list_id]] | ||
) |> Repo.update_all([]) | ||
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.
@joshsmith I really feel this is the way to go with migrations.
If our schema modules do not match the schemas in any migration step, the code will fail, but if we go like this, "schemaless", the only case where the migration step would not match the actual state of the schema were if we somehow run it manually, out of order, which would be incorrect usage of the migration.
I understand using actual schema modules and changesets in a seed script, but they should not be used in migrations.
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 really like 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.
Unfortunately it looks like this will override some of the work that was done in the earlier migration that moved tasks to closed, because this is not checking for whether the issues are closed.
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 You are correct about checking for gi not closed. You could also check for task not closed, it would likely serve the same purpose, since presumably, the task is otherwise in sync with the issue.
On a similar note, my other migration should probably add a clause for archived. I'm not sure what the exact query would be, but it would likely involve a where: date_add(t.modified_at, 30, "day") > ^Date.utc_today
somewhere in it.
I can't push the change myself due to not being home, but that should help.
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.
👍
test "defaults :pull_requests to 'false'" do | ||
{:ok, record} = | ||
%TaskList{} |> TaskList.changeset(@valid_attrs) |> Repo.insert | ||
assert record.pull_requests == false |
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.
🤦♂️
|> Repo.insert | ||
|
||
refute changeset.valid? | ||
assert changeset |> Map.get(:errors) |> Keyword.get(:done) |
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.
minor spacing...unless its the GUI.
|
||
create unique_index( | ||
"task_lists", [:project_id], | ||
where: "done = true", name: "task_lists_project_id_done_index") |
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.
Nice work!!
where: not is_nil(gi.github_pull_request_id), | ||
update: [set: [task_list_id: ^pr_list_id]] | ||
) |> Repo.update_all([]) | ||
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.
I really like this.
where: not is_nil(gi.github_pull_request_id), | ||
update: [set: [task_list_id: ^pr_list_id]] | ||
) |> Repo.update_all([]) | ||
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.
Unfortunately it looks like this will override some of the work that was done in the earlier migration that moved tasks to closed, because this is not checking for whether the issues are closed.
dff22be
to
994f7f3
Compare
Fixes #1151, fixes #1152