Skip to content

Commit 7badcf4

Browse files
authored
Merge pull request #704 from code-corps/remove-task-types
Remove task types
2 parents de25f2e + 1f4bd09 commit 7badcf4

17 files changed

Lines changed: 29 additions & 102 deletions

File tree

blueprint/api.apib

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2759,7 +2759,6 @@ This endpoint allows you to check whether a username is valid (by running a vali
27592759
+ number: 1 (string)
27602760
+ status: `open` (string)
27612761
+ state: `published` (string)
2762-
+ `task-type`: `task` (string)
27632762
+ title: `Example task` (string)
27642763
+ `updated-at`: `2016-07-08T03:03:51.967Z` (string)
27652764

lib/code_corps/analytics/segment_traits_builder.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ defmodule CodeCorps.Analytics.SegmentTraitsBuilder do
2626
comment_id: comment.id,
2727
task: comment.task.title,
2828
task_id: comment.task.id,
29-
task_type: comment.task.task_type,
3029
project_id: comment.task.project_id
3130
}
3231
end
@@ -56,7 +55,6 @@ defmodule CodeCorps.Analytics.SegmentTraitsBuilder do
5655
%{
5756
task: task.title,
5857
task_id: task.id,
59-
task_type: task.task_type,
6058
project_id: task.project_id
6159
}
6260
end

lib/code_corps/helpers/query.ex

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule CodeCorps.Helpers.Query do
2-
import CodeCorps.Helpers.String, only: [coalesce_id_string: 1, coalesce_string: 1]
2+
import CodeCorps.Helpers.String, only: [coalesce_id_string: 1]
33
import Ecto.Query, only: [where: 3, limit: 2, order_by: 2]
44

55
def id_filter(query, id_list) do
@@ -44,12 +44,6 @@ defmodule CodeCorps.Helpers.Query do
4444
end
4545
def task_list_filter(query, _), do: query
4646

47-
def task_type_filter(query, %{"task_type" => task_type_list}) do
48-
task_types = task_type_list |> coalesce_string
49-
query |> where([object], object.task_type in ^task_types)
50-
end
51-
def task_type_filter(query, _), do: query
52-
5347
def task_status_filter(query, %{"status" => status}) do
5448
query |> where([object], object.status == ^status)
5549
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmodule CodeCorps.Repo.Migrations.RemoveTaskTypeFromTasks do
2+
use Ecto.Migration
3+
4+
def change do
5+
alter table(:tasks) do
6+
remove :task_type
7+
end
8+
end
9+
end

priv/repo/seeds.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ cond do
303303
|> Task.create_changeset(%{
304304
title: "test task #{i}",
305305
markdown: "test *body* #{i}",
306-
task_type: Enum.random(~w{idea issue task}),
307306
status: "open",
308307
number: i,
309308
project_id: 1,

priv/repo/structure.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,6 @@ CREATE TABLE tasks (
11051105
body text,
11061106
markdown text,
11071107
number integer NOT NULL,
1108-
task_type character varying(255) DEFAULT 'task'::character varying NOT NULL,
11091108
state character varying(255) NOT NULL,
11101109
status character varying(255) DEFAULT 'open'::character varying NOT NULL,
11111110
title text NOT NULL,
@@ -2520,5 +2519,5 @@ ALTER TABLE ONLY user_tasks
25202519
-- PostgreSQL database dump complete
25212520
--
25222521

2523-
INSERT INTO "schema_migrations" (version) VALUES (20160723215749), (20160804000000), (20160804001111), (20160805132301), (20160805203929), (20160808143454), (20160809214736), (20160810124357), (20160815125009), (20160815143002), (20160816020347), (20160816034021), (20160817220118), (20160818000944), (20160818132546), (20160820113856), (20160820164905), (20160822002438), (20160822004056), (20160822011624), (20160822020401), (20160822044612), (20160830081224), (20160830224802), (20160911233738), (20160912002705), (20160912145957), (20160918003206), (20160928232404), (20161003185918), (20161019090945), (20161019110737), (20161020144622), (20161021131026), (20161031001615), (20161121005339), (20161121014050), (20161121043941), (20161121045709), (20161122015942), (20161123081114), (20161123150943), (20161124085742), (20161125200620), (20161126045705), (20161127054559), (20161205024856), (20161207112519), (20161209192504), (20161212005641), (20161214005935), (20161215052051), (20161216051447), (20161218005913), (20161219160401), (20161219163909), (20161220141753), (20161221085759), (20161226213600), (20161231063614), (20170102130055), (20170102181053), (20170104113708), (20170104212623), (20170104235423), (20170106013143), (20170115035159), (20170115230549), (20170121014100), (20170131234029), (20170201014901), (20170201025454), (20170201035458), (20170201183258);
2522+
INSERT INTO "schema_migrations" (version) VALUES (20160723215749), (20160804000000), (20160804001111), (20160805132301), (20160805203929), (20160808143454), (20160809214736), (20160810124357), (20160815125009), (20160815143002), (20160816020347), (20160816034021), (20160817220118), (20160818000944), (20160818132546), (20160820113856), (20160820164905), (20160822002438), (20160822004056), (20160822011624), (20160822020401), (20160822044612), (20160830081224), (20160830224802), (20160911233738), (20160912002705), (20160912145957), (20160918003206), (20160928232404), (20161003185918), (20161019090945), (20161019110737), (20161020144622), (20161021131026), (20161031001615), (20161121005339), (20161121014050), (20161121043941), (20161121045709), (20161122015942), (20161123081114), (20161123150943), (20161124085742), (20161125200620), (20161126045705), (20161127054559), (20161205024856), (20161207112519), (20161209192504), (20161212005641), (20161214005935), (20161215052051), (20161216051447), (20161218005913), (20161219160401), (20161219163909), (20161220141753), (20161221085759), (20161226213600), (20161231063614), (20170102130055), (20170102181053), (20170104113708), (20170104212623), (20170104235423), (20170106013143), (20170115035159), (20170115230549), (20170121014100), (20170131234029), (20170201014901), (20170201025454), (20170201035458), (20170201183258), (20170220032224);
25242523

test/controllers/comment_controller_test.exs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ defmodule CodeCorps.CommentControllerTest do
5656
comment_id: String.to_integer(json["data"]["id"]),
5757
task: task.title,
5858
task_id: task.id,
59-
task_type: task.task_type,
6059
project_id: task.project_id
6160
}
6261

@@ -94,7 +93,6 @@ defmodule CodeCorps.CommentControllerTest do
9493
comment_id: comment.id,
9594
task: task.title,
9695
task_id: task.id,
97-
task_type: task.task_type,
9896
project_id: task.project_id
9997
}
10098

test/controllers/task_controller_test.exs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ defmodule CodeCorps.TaskControllerTest do
33

44
@valid_attrs %{
55
title: "Test task",
6-
task_type: "issue",
76
markdown: "A test task",
87
status: "open"
98
}
109

1110
@invalid_attrs %{
1211
title: nil,
13-
task_type: "issue",
1412
status: "nonexistent"
1513
}
1614

@@ -59,30 +57,6 @@ defmodule CodeCorps.TaskControllerTest do
5957
assert json["data"] |> Enum.count == 2
6058
end
6159

62-
test "lists all tasks filtered by task_type", %{conn: conn} do
63-
project_1 = insert(:project)
64-
user = insert(:user)
65-
insert(:task, task_type: "idea", project: project_1, user: user)
66-
insert(:task, task_type: "issue", project: project_1, user: user)
67-
insert(:task, task_type: "task", project: project_1, user: user)
68-
69-
json =
70-
conn
71-
|> get("projects/#{project_1.id}/tasks?task_type=idea,issue")
72-
|> json_response(200)
73-
74-
assert json["data"] |> Enum.count == 2
75-
76-
task_types =
77-
json["data"]
78-
|> Enum.map(fn(task_json) -> task_json["attributes"] end)
79-
|> Enum.map(fn(task_attributes) -> task_attributes["task-type"] end)
80-
81-
assert task_types |> Enum.member?("issue")
82-
assert task_types |> Enum.member?("idea")
83-
refute task_types |> Enum.member?("task")
84-
end
85-
8660
test "lists all tasks filtered by status", %{conn: conn} do
8761
project = insert(:project)
8862
task_1 = insert(:task, status: "open", project: project)
@@ -150,7 +124,6 @@ defmodule CodeCorps.TaskControllerTest do
150124
tracking_properties = %{
151125
task: @valid_attrs.title,
152126
task_id: String.to_integer(json["data"]["id"]),
153-
task_type: @valid_attrs.task_type,
154127
project_id: project.id
155128
}
156129

@@ -179,7 +152,6 @@ defmodule CodeCorps.TaskControllerTest do
179152
tracking_properties = %{
180153
task: task.title,
181154
task_id: task.id,
182-
task_type: task.task_type,
183155
project_id: task.project.id
184156
}
185157

test/lib/code_corps/services/markdown_renderer_test.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ defmodule CodeCorps.Services.MarkdownRendererServiceTest do
88
@valid_attrs %{
99
title: "Test task",
1010
task_list_id: 1,
11-
task_type: "issue",
1211
markdown: "A **strong** body",
1312
status: "open"
1413
}

test/models/task_test.exs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,16 @@ defmodule CodeCorps.TaskTest do
55

66
@valid_attrs %{
77
title: "Test task",
8-
task_type: "issue",
98
markdown: "A test task"
109
}
11-
@invalid_attrs %{
12-
task_type: "nonexistent"
13-
}
10+
@invalid_attrs %{}
1411

1512
describe "create/2" do
1613
test "is invalid with invalid attributes" do
1714
changeset = Task.changeset(%Task{}, @invalid_attrs)
1815
refute changeset.valid?
1916
end
2017

21-
test "only allows specific values for task_type" do
22-
changes = Map.put(@valid_attrs, :task_type, "nonexistent")
23-
changeset = Task.changeset(%Task{}, changes)
24-
refute changeset.valid?
25-
end
26-
2718
test "renders body html from markdown" do
2819
user = insert(:user)
2920
project = insert(:project)
@@ -47,7 +38,6 @@ defmodule CodeCorps.TaskTest do
4738
task_list = insert(:task_list)
4839
changeset = Task.create_changeset(%Task{}, %{
4940
markdown: "some content",
50-
task_type: "issue",
5141
title: "some content",
5242
project_id: project.id,
5343
user_id: user.id,

0 commit comments

Comments
 (0)