Skip to content

Commit 607800f

Browse files
committed
rename Repo.transact into tx to avoid conflicts
1 parent 8702a84 commit 607800f

File tree

14 files changed

+39
-39
lines changed

14 files changed

+39
-39
lines changed

lib/algora/accounts/accounts.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ defmodule Algora.Accounts do
320320
github_user = Repo.get_by(User, provider: "github", provider_id: to_string(info["id"]))
321321
email_user = Repo.get_by(User, email: primary_email)
322322

323-
Repo.transact(fn ->
323+
Repo.tx(fn ->
324324
Repo.delete_all(from(i in Identity, where: i.provider == "github" and i.provider_id == ^to_string(info["id"])))
325325

326326
with true <- github_user && github_user.id != user.id,

lib/algora/bounties/bounties.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ defmodule Algora.Bounties do
135135
command_id = opts[:command_id]
136136
shared_with = opts[:shared_with] || []
137137

138-
Repo.transact(fn ->
138+
Repo.tx(fn ->
139139
with {:ok, %{installation_id: installation_id, token: token}} <-
140140
Workspace.resolve_installation_and_token(opts[:installation_id], repo_owner, creator),
141141
{:ok, ticket} <- Workspace.ensure_ticket(token, repo_owner, repo_name, number),
@@ -213,7 +213,7 @@ defmodule Algora.Bounties do
213213
def create_bounty(%{creator: creator, owner: owner, amount: amount, title: title, description: description}, opts) do
214214
shared_with = opts[:shared_with] || []
215215

216-
Repo.transact(fn ->
216+
Repo.tx(fn ->
217217
with {:ok, ticket} <-
218218
%Ticket{type: :issue}
219219
|> Ticket.changeset(%{title: title, description: description})
@@ -564,7 +564,7 @@ defmodule Algora.Bounties do
564564
},
565565
opts \\ []
566566
) do
567-
Repo.transact(fn ->
567+
Repo.tx(fn ->
568568
with {:ok, %{installation_id: installation_id, token: token}} <-
569569
Workspace.resolve_installation_and_token(opts[:installation_id], source_repo_owner, user),
570570
{:ok, target} <- Workspace.ensure_ticket(token, target_repo_owner, target_repo_name, target_number),
@@ -733,7 +733,7 @@ defmodule Algora.Bounties do
733733
) ::
734734
{:ok, String.t()} | {:error, atom()}
735735
def create_tip(%{creator: creator, owner: owner, recipient: recipient, amount: amount}, opts \\ []) do
736-
Repo.transact(fn ->
736+
Repo.tx(fn ->
737737
case do_create_tip(%{creator: creator, owner: owner, recipient: recipient, amount: amount}, opts) do
738738
{:ok, tip} ->
739739
create_payment_session(
@@ -957,7 +957,7 @@ defmodule Algora.Bounties do
957957

958958
bounty_id = if bounty = opts[:bounty], do: bounty.id
959959

960-
Repo.transact(fn ->
960+
Repo.tx(fn ->
961961
with {:ok, _charge} <-
962962
initialize_charge(%{
963963
id: Nanoid.generate(),
@@ -1019,7 +1019,7 @@ defmodule Algora.Bounties do
10191019

10201020
bounty_id = if bounty = opts[:bounty], do: bounty.id
10211021

1022-
Repo.transact(fn ->
1022+
Repo.tx(fn ->
10231023
with {:ok, _charge} <-
10241024
initialize_charge(%{
10251025
id: Nanoid.generate(),
@@ -1588,7 +1588,7 @@ defmodule Algora.Bounties do
15881588

15891589
@spec delete_bounty(Bounty.t()) :: {:ok, Bounty.t()} | {:error, Ecto.Changeset.t()}
15901590
def delete_bounty(%Bounty{} = bounty) do
1591-
Repo.transact(fn ->
1591+
Repo.tx(fn ->
15921592
with {:ok, updated_bounty} <-
15931593
bounty
15941594
|> Bounty.changeset(%{status: :cancelled})

lib/algora/contracts/contracts.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ defmodule Algora.Contracts do
363363
amount: transfer_amount
364364
}
365365

366-
Repo.transact(fn ->
366+
Repo.tx(fn ->
367367
with {:ok, charge} <- maybe_initialize_charge(charge_params),
368368
{:ok, debit} <- initialize_debit(debit_params),
369369
{:ok, credit} <- initialize_credit(credit_params),

lib/algora/integrations/github/poller/deliveries.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ defmodule Algora.Github.Poller.Deliveries do
103103
defp process_batch([], state), do: {:ok, state.cursor}
104104

105105
defp process_batch(deliveries, state) do
106-
Repo.transact(fn ->
106+
Repo.tx(fn ->
107107
with :ok <- process_deliveries(deliveries, state) do
108108
update_last_polled(state.cursor, List.first(deliveries))
109109
end

lib/algora/integrations/github/poller/search.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ defmodule Algora.Github.Poller.Search do
109109
defp process_batch([], state), do: {:ok, state.cursor}
110110

111111
defp process_batch(tickets, state) do
112-
Repo.transact(fn ->
112+
Repo.tx(fn ->
113113
with :ok <- process_tickets(tickets, state) do
114114
timestamps =
115115
tickets

lib/algora/jobs/jobs.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ defmodule Algora.Jobs do
137137

138138
job_posting = Repo.preload(job_posting, :user)
139139

140-
Repo.transact(fn ->
140+
Repo.tx(fn ->
141141
with {:ok, _charge} <-
142142
%Transaction{}
143143
|> change(%{

lib/algora/matches/matches.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ defmodule Algora.Matches do
147147
}
148148
end)
149149

150-
Repo.transact(fn ->
150+
Repo.tx(fn ->
151151
# Delete existing matches for this job posting
152152
Repo.delete_all(
153153
from(m in JobMatch,

lib/algora/organizations/organizations.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ defmodule Algora.Organizations do
5757
org -> org.handle
5858
end
5959

60-
Repo.transact(fn ->
60+
Repo.tx(fn ->
6161
{:ok, user} =
6262
case Repo.get_by(User, email: params.user.email) do
6363
nil ->
@@ -352,7 +352,7 @@ defmodule Algora.Organizations do
352352
{:ok, owner} <- Workspace.ensure_user(token, repo_owner),
353353
{:ok, _contributors} <- Workspace.ensure_contributors(token, repo),
354354
{:ok, tech_stack} <- Workspace.ensure_repo_tech_stack(token, repo) do
355-
Repo.transact(fn _ ->
355+
Repo.tx(fn _ ->
356356
with {:ok, org} <-
357357
Repo.insert(%User{
358358
type: :organization,

lib/algora/payments/payments.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ defmodule Algora.Payments do
478478

479479
@spec enqueue_pending_transfers(user_id :: String.t()) :: {:ok, nil} | {:error, term()}
480480
def enqueue_pending_transfers(user_id) do
481-
Repo.transact(fn ->
481+
Repo.tx(fn ->
482482
with {:ok, _account} <- fetch_active_account(user_id),
483483
credits = list_payable_credits(user_id),
484484
:ok <-
@@ -590,7 +590,7 @@ defmodule Algora.Payments do
590590
%Stripe.Charge{id: charge_id, captured: false, payment_intent: payment_intent_id},
591591
group_id
592592
) do
593-
Repo.transact(fn ->
593+
Repo.tx(fn ->
594594
Repo.update_all(from(t in Transaction, where: t.group_id == ^group_id, where: t.type == :charge),
595595
set: [
596596
status: :requires_capture,
@@ -611,7 +611,7 @@ defmodule Algora.Payments do
611611
%Stripe.Charge{id: charge_id, captured: true, payment_intent: payment_intent_id},
612612
group_id
613613
) do
614-
Repo.transact(fn ->
614+
Repo.tx(fn ->
615615
Repo.update_all(from(t in Transaction, where: t.group_id == ^group_id, where: t.type == :charge),
616616
set: [
617617
status: :succeeded,
@@ -642,7 +642,7 @@ defmodule Algora.Payments do
642642
%Stripe.Charge{id: charge_id, captured: true, payment_intent: payment_intent_id},
643643
group_id
644644
) do
645-
Repo.transact(fn ->
645+
Repo.tx(fn ->
646646
{_, txs} =
647647
Repo.update_all(from(t in Transaction, where: t.group_id == ^group_id, select: t),
648648
set: [
@@ -771,7 +771,7 @@ defmodule Algora.Payments do
771771
amount,
772772
recipient
773773
) do
774-
Repo.transact(fn ->
774+
Repo.tx(fn ->
775775
tx = Repo.get_by(Transaction, group_id: group_id, type: :charge, status: :succeeded)
776776

777777
user = Repo.get_by(User, id: tx.user_id)

lib/algora/repo.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ defmodule Algora.Repo do
5353
fetch_one(query, opts)
5454
end
5555

56-
@spec transact(fun(), Keyword.t()) :: term()
57-
def transact(fun, opts \\ []) do
56+
@spec tx(fun(), Keyword.t()) :: term()
57+
def tx(fun, opts \\ []) do
5858
transaction(
5959
fn repo ->
6060
result =

0 commit comments

Comments
 (0)