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

Upgrade to Ecto 3 #1984

Merged
merged 12 commits into from
May 29, 2020
Merged

Upgrade to Ecto 3 #1984

merged 12 commits into from
May 29, 2020

Conversation

IvanIvanoff
Copy link
Member

@IvanIvanoff IvanIvanoff commented May 18, 2020

Summary

Changed dependencies:
Clickhousex: https://github.com/IvanIvanoff/clickhousex
ClickhouseEcto: http://github.com/santiment/clickhouse_ecto/pull/6
ExAdmin: santiment/ex_admin#1

These dependencies are not in santiment master branches because this would break current builds (before this is merged). After merging this, testing on stage and deploying to prod we can safely move all dependencies to sentiment master branches.


Some useful links connected to ecto 2 -> 3 migrations when work on adapters is required
https://github.com/elixir-ecto/ecto/blob/master/CHANGELOG.md#adapter-changes
elixir-ecto/db_connection#167
https://elixirforum.com/t/how-much-work-to-update-an-ecto2-adapter-to-ecto3/18689/12

All clickhouse tests are done with mocks. The adapter is needed so a
connection can be established and we do not get Repo not started error.
The postgres db won't ever be queried from ClickhouseRepo
@IvanIvanoff IvanIvanoff marked this pull request as ready for review May 27, 2020 09:28
@IvanIvanoff IvanIvanoff requested a review from tspenov May 27, 2020 09:28
lib/sanbase/auth/user.ex Outdated Show resolved Hide resolved
config/test.exs Show resolved Hide resolved
lib/sanbase/clickhouse_repo.ex Show resolved Hide resolved
lib/sanbase/insight/post.ex Outdated Show resolved Hide resolved
@@ -61,7 +61,7 @@ defmodule Sanbase.Insight.Post do
on_delete: :delete_all
)

field(:published_at, :naive_datetime)
field(:published_at, :naive_datetime_usec)
Copy link
Contributor

Choose a reason for hiding this comment

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

is that required to fix datetime comparisons in tests ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think i'll revert back to naive_datetime and change the tests so different insights have a full second difference in creation time

@@ -4,14 +4,14 @@ defmodule Sanbase.Timeline.Cursor do
def filter_by_cursor(query, :before, datetime) do
from(
event in query,
where: event.inserted_at < ^datetime
where: event.inserted_at < ^DateTime.to_naive(datetime)
Copy link
Contributor

Choose a reason for hiding this comment

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

We have to convert to naive in order to user comparison with datetime field in query ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure and have to double-check

lib/sanbase/voting/vote.ex Outdated Show resolved Hide resolved
end)
end
column("San balance", fn eth_account ->
case EthAccount.san_balance(eth_account) do
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it returns: san_balance | :error.
Also it will make a call to parity service on opening every user in admin in dev env

Copy link
Member Author

Choose a reason for hiding this comment

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

It's very very rare to open user ex_admin from dev. We already need a connection to some services using VPN, so parity is easy to enable as well

Copy link
Contributor

Choose a reason for hiding this comment

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

the san_balance function returns :error instead of nil

@IvanIvanoff IvanIvanoff merged commit 5e849a5 into master May 29, 2020
@delete-merged-branch delete-merged-branch bot deleted the ecto-3 branch May 29, 2020 14:53
@IvanIvanoff IvanIvanoff restored the ecto-3 branch June 1, 2020 11:17
@IvanIvanoff IvanIvanoff deleted the ecto-3 branch June 1, 2020 11:17
@IvanIvanoff IvanIvanoff restored the ecto-3 branch June 1, 2020 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants