Skip to content

Commit 8a69ca9

Browse files
committed
fix: exclude test organizations from migration transactions
1 parent 756d056 commit 8a69ca9

File tree

1 file changed

+40
-38
lines changed

1 file changed

+40
-38
lines changed

scripts/database_migration.exs

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ defmodule DatabaseMigration do
7474
{"Reward", ["bounty_id"]}
7575
]
7676

77-
@test_org_id "cljo6j981000el60f1k1cvtns"
77+
@test_orgs ["cljo6j981000el60f1k1cvtns", "clcqf530c0001jy08mdisnzmj"]
7878

7979
defp relevant_tables do
8080
@schema_mappings
@@ -362,7 +362,7 @@ defmodule DatabaseMigration do
362362

363363
transfer = find_by_index(db, "_BountyTransfer", "bounty_id", row["id"])
364364

365-
if row["type"] != "tip" do
365+
if row["type"] != "tip" and owner["id"] not in @test_orgs do
366366
%{
367367
"id" => row["id"],
368368
"amount" => amount,
@@ -473,7 +473,7 @@ defmodule DatabaseMigration do
473473
raise "User not found: #{inspect(row)}"
474474
end
475475

476-
if !nullish?(row["succeeded_at"]) do
476+
if !nullish?(row["succeeded_at"]) and user["id"] not in @test_orgs do
477477
%{
478478
"id" => row["id"],
479479
"provider" => "stripe",
@@ -535,7 +535,7 @@ defmodule DatabaseMigration do
535535
raise "Owner not found: #{inspect(row)}"
536536
end
537537

538-
if bounty["type"] == "tip" and !nullish?(bounty_charge["succeeded_at"]) do
538+
if bounty["type"] == "tip" and !nullish?(bounty_charge["succeeded_at"]) and owner["id"] not in @test_orgs do
539539
%{
540540
"id" => bounty["id"] <> user_id,
541541
"amount" => amount,
@@ -575,7 +575,7 @@ defmodule DatabaseMigration do
575575
raise "BountyCharge not found: #{inspect(row)}"
576576
end
577577

578-
if !nullish?(bounty_charge["succeeded_at"]) do
578+
if !nullish?(bounty_charge["succeeded_at"]) and org["id"] not in @test_orgs do
579579
Enum.reject(
580580
[
581581
maybe_create_transaction("debit", %{
@@ -624,37 +624,39 @@ defmodule DatabaseMigration do
624624
{Money.negate!(amount), "debit"}
625625
end
626626

627-
%{
628-
"id" => row["id"],
629-
"provider" => "stripe",
630-
"provider_id" => nil,
631-
"provider_charge_id" => nil,
632-
"provider_payment_intent_id" => nil,
633-
"provider_transfer_id" => nil,
634-
"provider_invoice_id" => nil,
635-
"provider_balance_transaction_id" => nil,
636-
"provider_meta" => nil,
637-
"gross_amount" => abs_amount,
638-
"net_amount" => abs_amount,
639-
"total_fee" => Money.zero(:USD),
640-
"provider_fee" => nil,
641-
"line_items" => nil,
642-
"type" => type,
643-
"status" => :succeeded,
644-
"succeeded_at" => row["created_at"],
645-
"reversed_at" => nil,
646-
"group_id" => row["id"],
647-
"user_id" => user["id"],
648-
"contract_id" => nil,
649-
"original_contract_id" => nil,
650-
"timesheet_id" => nil,
651-
"bounty_id" => nil,
652-
"tip_id" => nil,
653-
"linked_transaction_id" => nil,
654-
"inserted_at" => row["created_at"],
655-
"updated_at" => row["created_at"],
656-
"claim_id" => nil
657-
}
627+
if user["id"] not in @test_orgs do
628+
%{
629+
"id" => row["id"],
630+
"provider" => "stripe",
631+
"provider_id" => nil,
632+
"provider_charge_id" => nil,
633+
"provider_payment_intent_id" => nil,
634+
"provider_transfer_id" => nil,
635+
"provider_invoice_id" => nil,
636+
"provider_balance_transaction_id" => nil,
637+
"provider_meta" => nil,
638+
"gross_amount" => abs_amount,
639+
"net_amount" => abs_amount,
640+
"total_fee" => Money.zero(:USD),
641+
"provider_fee" => nil,
642+
"line_items" => nil,
643+
"type" => type,
644+
"status" => :succeeded,
645+
"succeeded_at" => row["created_at"],
646+
"reversed_at" => nil,
647+
"group_id" => row["id"],
648+
"user_id" => user["id"],
649+
"contract_id" => nil,
650+
"original_contract_id" => nil,
651+
"timesheet_id" => nil,
652+
"bounty_id" => nil,
653+
"tip_id" => nil,
654+
"linked_transaction_id" => nil,
655+
"inserted_at" => row["created_at"],
656+
"updated_at" => row["created_at"],
657+
"claim_id" => nil
658+
}
659+
end
658660
end
659661

660662
defp transform({"GithubInstallation", Installation}, row, db) do
@@ -709,7 +711,7 @@ defmodule DatabaseMigration do
709711
raise "Owner not found: #{inspect(row)}"
710712
end
711713

712-
if owner["id"] != @test_org_id do
714+
if owner["id"] not in @test_orgs do
713715
%{
714716
"id" => row["id"],
715717
"provider" => "stripe",
@@ -736,7 +738,7 @@ defmodule DatabaseMigration do
736738
raise "StripeCustomer not found: #{inspect(row)}"
737739
end
738740

739-
if owner["id"] != @test_org_id do
741+
if owner["id"] not in @test_orgs do
740742
%{
741743
"id" => row["id"],
742744
"provider" => "stripe",

0 commit comments

Comments
 (0)