|
1 | 1 | defmodule CodeCorpsWeb.TaskView do |
2 | 2 | @moduledoc false |
3 | 3 | use CodeCorpsWeb, :view |
4 | | - use JaSerializer.PhoenixView |
| 4 | + use JSONAPI.View, type: "task" |
5 | 5 |
|
6 | | - attributes [ |
7 | | - :archived, :body, :created_at, :created_from, :has_github_pull_request, |
8 | | - :inserted_at, :markdown, :modified_at, :modified_from, :number, :order, |
9 | | - :overall_status, :status, :title, :updated_at |
10 | | - ] |
| 6 | + alias CodeCorpsWeb.{GithubIssueView, GithubPullRequestView, GithubRepoView, ProjectView, |
| 7 | + TaskListView, UserView, UserTaskView, CommentView, TaskSkillView} |
11 | 8 |
|
12 | | - has_one :github_issue, type: "github-issue", field: :github_issue_id |
13 | | - has_one :github_pull_request, serializer: CodeCorpsWeb.GithubPullRequestView, identifiers: :always |
14 | | - has_one :github_repo, type: "github-repo", field: :github_repo_id |
15 | | - has_one :project, type: "project", field: :project_id |
16 | | - has_one :task_list, type: "task-list", field: :task_list_id |
17 | | - has_one :user, type: "user", field: :user_id |
18 | | - has_one :user_task, serializer: CodeCorpsWeb.UserTaskView, identifiers: :always |
| 9 | + def fields do |
| 10 | + [:archived, :body, :created_at, :created_from, :inserted_at, :markdown, |
| 11 | + :modified_at, :modified_from, :number, :order, :status, :title, :updated_at] |
| 12 | + end |
19 | 13 |
|
20 | | - has_many :comments, serializer: CodeCorpsWeb.CommentView, identifiers: :always |
21 | | - has_many :task_skills, serializer: CodeCorpsWeb.TaskSkillView, identifiers: :always |
| 14 | + def relationships do |
| 15 | + [comments: CommentView, task_skills: TaskSkillView] |
| 16 | + end |
22 | 17 |
|
23 | | - def has_github_pull_request(%{ |
24 | | - github_pull_request: %CodeCorps.GithubPullRequest{} |
25 | | - }), do: true |
26 | | - def has_github_pull_request(%{github_pull_request: nil}), do: false |
| 18 | +# <<<<<<< HEAD |
| 19 | +# has_many :comments, serializer: CodeCorpsWeb.CommentView, identifiers: :always |
| 20 | +# has_many :task_skills, serializer: CodeCorpsWeb.TaskSkillView, identifiers: :always |
27 | 21 |
|
28 | | - def overall_status(%{ |
29 | | - github_pull_request: %CodeCorps.GithubPullRequest{merged: merged, state: state} |
30 | | - }, _conn) do |
31 | | - case merged do |
32 | | - true -> "merged" |
33 | | - false -> state |
34 | | - end |
35 | | - end |
36 | | - def overall_status(%{github_pull_request: nil, status: status}, _conn) do |
37 | | - status |
38 | | - end |
| 22 | +# def has_github_pull_request(%{ |
| 23 | +# github_pull_request: %CodeCorps.GithubPullRequest{} |
| 24 | +# }), do: true |
| 25 | +# def has_github_pull_request(%{github_pull_request: nil}), do: false |
| 26 | + |
| 27 | +# def overall_status(%{ |
| 28 | +# github_pull_request: %CodeCorps.GithubPullRequest{merged: merged, state: state} |
| 29 | +# }, _conn) do |
| 30 | +# case merged do |
| 31 | +# true -> "merged" |
| 32 | +# false -> state |
| 33 | +# end |
| 34 | +# end |
| 35 | +# def overall_status(%{github_pull_request: nil, status: status}, _conn) do |
| 36 | +# status |
| 37 | +# end |
| 38 | +# ======= |
39 | 39 | end |
0 commit comments