Skip to content

Commit 11f7472

Browse files
committed
deps: Update ecto & related dependencies
1 parent 14b33fe commit 11f7472

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+159
-124
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v1
13-
- uses: actions/setup-elixir@v1.1.0
13+
- uses: erlef/setup-elixir@v1
1414
with:
15-
otp-version: 22.x
15+
otp-version: 22.2.7
1616
elixir-version: 1.10.1
1717
- name: Check format
1818
run: mix format --check-formatted
@@ -37,9 +37,9 @@ jobs:
3737
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
3838
restore-keys: |
3939
${{ runner.os }}-mix-
40-
- uses: actions/setup-elixir@v1.1.0
40+
- uses: erlef/setup-elixir@v1
4141
with:
42-
otp-version: 22.x
42+
otp-version: 22.2.7
4343
elixir-version: 1.10.1
4444
- name: Install dependencies
4545
run: mix deps.get

.github/workflows/e2e.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ jobs:
3232
with:
3333
path: build
3434
key: ${{ runner.os }}-mix-build
35-
- uses: actions/setup-elixir@v1.1.0
35+
- uses: erlef/setup-elixir@v1
3636
with:
37-
otp-version: 22.x
37+
otp-version: 22.2.7
3838
elixir-version: 1.10.1
3939
- name: Install API's dependencies
4040
run: mix deps.get

apps/cf/lib/accounts/accounts.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ defmodule CF.Accounts do
168168
end)
169169
|> User.provider_changeset(provider_params)
170170
)
171-
|> Multi.run(:final_user, fn %{base_user: user} ->
171+
|> Multi.run(:final_user, fn _repo, %{base_user: user} ->
172172
user
173173
|> User.changeset(%{})
174174
|> Ecto.Changeset.put_change(:username, UsernameGenerator.generate(user.id))
@@ -373,12 +373,12 @@ defmodule CF.Accounts do
373373
"""
374374
def check_reset_password_token!(token) do
375375
date_limit =
376-
DateTime.utc_now()
377-
|> DateTime.to_naive()
376+
NaiveDateTime.utc_now()
377+
|> NaiveDateTime.truncate(:second)
378378
|> NaiveDateTime.add(-@request_validity, :second)
379379

380380
User
381-
|> join(:inner, [u], r in ResetPasswordRequest, r.user_id == u.id)
381+
|> join(:inner, [u], r in ResetPasswordRequest, on: r.user_id == u.id)
382382
|> where([u, r], r.token == ^token)
383383
|> where([u, r], r.inserted_at >= ^date_limit)
384384
|> Repo.one!()

apps/cf/lib/accounts/invitations.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ defmodule CF.Accounts.Invitations do
153153
do: generate_invites(number, TokenGenerator.generate(@default_token_length))
154154

155155
def generate_invites(number, token) do
156-
time = Ecto.DateTime.utc()
156+
time = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
157157

158158
Repo.insert_all(
159159
InvitationRequest,

apps/cf/lib/actions/action_creator.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ defmodule CF.Actions.ActionCreator do
105105
)
106106
end
107107

108-
def action_update(user_id, %{data: %Speaker{id: id}, changes: changes}, video_id) do
109-
action(user_id, :speaker, :update, speaker_id: id, video_id: video_id, changes: changes)
110-
end
111-
112108
def action_update(user_id, %{data: %Speaker{id: id}, changes: changes}) do
113109
action(user_id, :speaker, :update, speaker_id: id, changes: changes)
114110
end
@@ -118,6 +114,10 @@ defmodule CF.Actions.ActionCreator do
118114
action(user_id, :user, :update, logged_changes)
119115
end
120116

117+
def action_update(user_id, %{data: %Speaker{id: id}, changes: changes}, video_id) do
118+
action(user_id, :speaker, :update, speaker_id: id, video_id: video_id, changes: changes)
119+
end
120+
121121
# Remove
122122

123123
def action_remove(user_id, video_id, %Speaker{id: id}) do

apps/cf/lib/actions/actions.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ defmodule CF.Actions do
9696
do: query
9797

9898
defp age_filter(query, age) do
99-
datetime_now = NaiveDateTime.utc_now()
99+
datetime_now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
100100
datetime_start = NaiveDateTime.add(datetime_now, -age)
101101
ActionsQuery.for_period(query, datetime_start, datetime_now)
102102
end

apps/cf/lib/comments/comments.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,18 @@ defmodule CF.Comments do
5454
|> Comment.changeset(params)
5555

5656
Multi.new()
57-
|> Multi.run(:comment, fn _ ->
57+
|> Multi.run(:comment, fn _repo, _changes ->
5858
comment_changeset
5959
|> Repo.insert!()
6060
|> Map.put(:user, user)
6161
|> Repo.preload([:source, :statement])
6262
|> Map.put(:score, 0)
6363
|> Result.ok()
6464
end)
65-
|> Multi.run(:action, fn %{comment: comment} ->
65+
|> Multi.run(:action, fn _repo, %{comment: comment} ->
6666
Repo.insert(action_create(user.id, video_id, comment, source_url))
6767
end)
68-
|> Multi.run(:suscription, fn %{comment: comment} ->
68+
|> Multi.run(:suscription, fn _repo, %{comment: comment} ->
6969
Subscriptions.subscribe(user, comment, :is_author)
7070
end)
7171
|> Repo.transaction()

apps/cf/lib/moderation/moderation.ex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ defmodule CF.Moderation do
8888
UserAction
8989
|> without_user_feedback(user)
9090
|> where([a, _], a.id == ^action_id)
91-
|> join(:inner, [a, _], f in Flag, f.action_id == a.id)
91+
|> join(:inner, [a, _], f in Flag, on: f.action_id == a.id)
9292
|> group_by([a, _, _], a.id)
9393
# Following conditions will fail if target action is not reported. This is on purpose
9494
|> being_reported()
@@ -110,6 +110,7 @@ defmodule CF.Moderation do
110110
Comment
111111
|> where([c], c.id == ^comment_id)
112112
|> where([c], c.is_reported == false)
113+
|> select([c], c)
113114
|> Repo.update_all([set: [is_reported: true]], returning: true)
114115
|> case do
115116
{1, [comment]} ->
@@ -124,7 +125,7 @@ defmodule CF.Moderation do
124125

125126
defp without_user_feedback(query, user) do
126127
query
127-
|> join(:left, [a], fb in subquery(user_feedbacks(user)), fb.action_id == a.id)
128+
|> join(:left, [a], fb in subquery(user_feedbacks(user)), on: fb.action_id == a.id)
128129
|> where([_, fb], is_nil(fb.action_id))
129130
end
130131

@@ -147,7 +148,7 @@ defmodule CF.Moderation do
147148
query
148149
|> where([a], a.user_id != ^user.id)
149150
|> without_user_feedback(user)
150-
|> join(:inner, [a, _], f in Flag, f.action_id == a.id)
151+
|> join(:inner, [a, _], f in Flag, on: f.action_id == a.id)
151152
|> group_by([a, _, _], a.id)
152153
|> being_reported()
153154
end

apps/cf/lib/speakers/speakers.ex

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ defmodule CF.Speakers do
1919
case SpeakerPicture.store({picture_url, speaker}) do
2020
{:ok, picture} ->
2121
speaker
22-
|> Ecto.Changeset.change(picture: %{file_name: picture, updated_at: DateTime.utc_now()})
22+
|> Ecto.Changeset.change(
23+
picture: %{
24+
file_name: picture,
25+
updated_at: NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
26+
}
27+
)
2328
|> Repo.update()
2429

2530
error ->
@@ -31,7 +36,7 @@ defmodule CF.Speakers do
3136
Calls `fetch_picture/2` with the picture retrieved from wikidata using
3237
`retrieve_wikimedia_picture_url/1`
3338
"""
34-
def fetch_picture_from_wikimedia(speaker = %Speaker{wikidata_item_id: nil}) do
39+
def fetch_picture_from_wikimedia(_speaker = %Speaker{wikidata_item_id: nil}) do
3540
{:error, "Cannot fetch picture from wikimedia if wikidata_item_id is no set"}
3641
end
3742

@@ -81,18 +86,16 @@ defmodule CF.Speakers do
8186
Logger.warn("Wikidata query failed: #{error.reason}")
8287
{:error, "Connection failed"}
8388

84-
e ->
89+
_e ->
8590
Logger.info("No picture found for #{speaker.full_name}")
8691
{:error, "No picture found"}
8792
end
8893
end
8994

90-
@merged_profile_fields [:full_name, :title, :country, :wikidata_item_id, :picture]
91-
9295
def merge_speakers(speaker_from, speaker_into) do
9396
Ecto.Multi.new()
9497
# Update speaker profile
95-
|> Ecto.Multi.run(:speaker_into, fn _ ->
98+
|> Ecto.Multi.run(:speaker_into, fn _repo, _ ->
9699
speaker_into
97100
|> Speaker.changeset(merge_speakers_fields(speaker_from, speaker_into))
98101
|> Repo.update()

apps/cf/lib/videos/videos.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ defmodule CF.Videos do
4141
"""
4242
def added_by_user(user, paginate_options \\ []) do
4343
Video
44-
|> join(:inner, [v], a in DB.Schema.UserAction, a.video_id == v.id)
44+
|> join(:inner, [v], a in DB.Schema.UserAction, on: a.video_id == v.id)
4545
|> where([_, a], a.user_id == ^user.id)
4646
|> where([_, a], a.type == ^:add and a.entity == ^:video)
4747
|> DB.Query.order_by_last_inserted_desc()
@@ -93,12 +93,12 @@ defmodule CF.Videos do
9393

9494
Multi.new()
9595
|> Multi.insert(:video_without_hash_id, Video.changeset(base_video, metadata))
96-
|> Multi.run(:video, fn %{video_without_hash_id: video} ->
96+
|> Multi.run(:video, fn _repo, %{video_without_hash_id: video} ->
9797
video
9898
|> Video.changeset_generate_hash_id()
9999
|> Repo.update()
100100
end)
101-
|> Multi.run(:action, fn %{video: video} ->
101+
|> Multi.run(:action, fn _repo, %{video: video} ->
102102
Repo.insert(ActionCreator.action_add(user.id, video))
103103
end)
104104
|> Repo.transaction()

0 commit comments

Comments
 (0)