Skip to content
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

Fix a number of warnings and change log levels #987

Merged
merged 1 commit into from
Sep 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/code_corps/comment/service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ defmodule CodeCorps.Comment.Service do
defp marshall_result({:ok, %{github: %Comment{} = comment}}), do: {:ok, comment}
defp marshall_result({:error, :comment, %Changeset{} = changeset, _steps}), do: {:error, changeset}
defp marshall_result({:error, :github, result, _steps}) do
Logger.warn "An error occurred when creating/updating the comment with the GitHub API"
Logger.warn "#{inspect result}"
Logger.info "An error occurred when creating/updating the comment with the GitHub API"
Logger.info "#{inspect result}"
{:error, :github}
end

Expand Down
34 changes: 18 additions & 16 deletions lib/code_corps/github/comment/comment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ defmodule CodeCorps.GitHub.Comment do
alias CodeCorps.{Comment, GitHub, GithubAppInstallation, GithubRepo, Task, User}

@spec create(Comment.t) :: GitHub.response
def create(%Comment{
task: %Task{
github_repo: %GithubRepo{
github_app_installation: %GithubAppInstallation{} = installation
}
} = task,
user:
%User{} = user} = comment) do
def create(
%Comment{
task: %Task{
github_repo: %GithubRepo{
github_app_installation: %GithubAppInstallation{} = installation
}
},
user: %User{} = user
} = comment) do

endpoint = comment |> create_endpoint_for()
attrs = comment |> GitHub.Adapters.Comment.to_github_comment
Expand All @@ -26,14 +27,15 @@ defmodule CodeCorps.GitHub.Comment do
end

@spec update(Comment.t) :: GitHub.response
def update(%Comment{
task: %Task{
github_repo: %GithubRepo{
github_app_installation: %GithubAppInstallation{} = installation
}
} = task,
user: %User{} = user,
github_id: id} = comment) do
def update(
%Comment{
task: %Task{
github_repo: %GithubRepo{
github_app_installation: %GithubAppInstallation{} = installation
}
},
user: %User{} = user
} = comment) do

endpoint = comment |> update_endpoint_for()
attrs = comment |> GitHub.Adapters.Comment.to_github_comment
Expand Down
4 changes: 2 additions & 2 deletions lib/code_corps/task/service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ defmodule CodeCorps.Task.Service do
defp marshall_result({:ok, %{github: %Task{} = task}}), do: {:ok, task}
defp marshall_result({:error, :task, %Changeset{} = changeset, _steps}), do: {:error, changeset}
defp marshall_result({:error, :github, result, _steps}) do
Logger.warn "An error occurred when creating/updating the task with the GitHub API"
Logger.warn "#{inspect result}"
Logger.info "An error occurred when creating/updating the task with the GitHub API"
Logger.info "#{inspect result}"
{:error, :github}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule CodeCorps.Repo.Migrations.AddStripeCustomersCardsTables do

def change do
create table(:stripe_customers) do
add :created, :datetime
add :created, :utc_datetime
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshsmith no need to replace field :created, :utc_datetime as well in the model?

Copy link
Contributor

@snewcomer snewcomer Sep 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I have seen done is for other models

@timestamps_opts [type: :utc_datetime] in the model file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind opening an issue for this? I'd like to migrate everything over to it specifically. We're lucky in the sense that the servers are all on UTC time by default so it shouldn't be a pain to migrate. But this is something that needs done ASAP.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I'm just trying to fix compiler warnings that will always be there unless we fix old migrations. That one was from Oct 2016!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. I'll open an issue.

add :currency, :string
add :delinquent, :boolean
add :email, :string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule CodeCorps.Repo.Migrations.CreateStripePlansStripeSubscriptions do
def change do
create table(:stripe_plans) do
add :amount, :integer
add :created, :datetime
add :created, :utc_datetime
add :id_from_stripe, :string, null: false
add :name, :string

Expand All @@ -17,16 +17,16 @@ defmodule CodeCorps.Repo.Migrations.CreateStripePlansStripeSubscriptions do

create table(:stripe_subscriptions) do
add :application_fee_percent, :decimal
add :cancelled_at, :datetime
add :cancelled_at, :utc_datetime
add :customer_id_from_stripe, :string
add :created, :datetime
add :current_period_end, :datetime
add :current_period_start, :datetime
add :ended_at, :datetime
add :created, :utc_datetime
add :current_period_end, :utc_datetime
add :current_period_start, :utc_datetime
add :ended_at, :utc_datetime
add :id_from_stripe, :string, null: false
add :plan_id_from_stripe, :string, null: false
add :quantity, :integer
add :start, :datetime
add :start, :utc_datetime
add :status, :string

add :stripe_plan_id, references(:stripe_plans), null: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule CodeCorps.Repo.Migrations.CreateStripeFileUpload do

def change do
create table(:stripe_file_upload) do
add :created, :datetime
add :created, :utc_datetime
add :id_from_stripe, :string, null: false
add :purpose, :string
add :size, :integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule CodeCorps.Repo.Migrations.AddVerificationFieldsToStripeConnectAccount
def change do
alter table(:stripe_connect_accounts) do
add :verification_disabled_reason, :string
add :verification_due_by, :datetime
add :verification_due_by, :utc_datetime
add :verification_fields_needed, {:array, :string}
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule CodeCorps.Repo.Migrations.AddTosAcceptanceFieldsToStripeConnectAccount

def change do
alter table(:stripe_connect_accounts) do
add :tos_acceptance_date, :datetime
add :tos_acceptance_date, :utc_datetime
add :tos_acceptance_ip, :string
add :tos_acceptance_user_agent, :string
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ defmodule CodeCorps.Repo.Migrations.ConvertStripeTimeStampsToIntegers do
remove :tos_acceptance_date
remove :verification_due_by

add :tos_acceptance_date, :datetime
add :verification_due_by, :datetime
add :tos_acceptance_date, :utc_datetime
add :verification_due_by, :utc_datetime
end

alter table(:stripe_platform_customers) do
remove :created
add :created, :datetime
add :created, :utc_datetime
end

alter table(:stripe_connect_plans) do
remove :created
add :created, :datetime
add :created, :utc_datetime
end

alter table(:stripe_connect_subscriptions) do
Expand All @@ -70,18 +70,18 @@ defmodule CodeCorps.Repo.Migrations.ConvertStripeTimeStampsToIntegers do
remove :ended_at
remove :start

add :cancelled_at, :datetime
add :created, :datetime
add :current_period_end, :datetime
add :current_period_start, :datetime
add :ended_at, :datetime
add :start, :datetime
add :cancelled_at, :utc_datetime
add :created, :utc_datetime
add :current_period_end, :utc_datetime
add :current_period_start, :utc_datetime
add :ended_at, :utc_datetime
add :start, :utc_datetime
end

alter table(:stripe_file_upload) do
remove :created

add :created, :datetime
add :created, :utc_datetime
end
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
defmodule CodeCorps.Repo.Migrations.AddEditableToTaskLists do
alias CodeCorps.{Repo, TaskList}

import Ecto.Query

use Ecto.Migration

def up do
Expand Down