Skip to content

Commit 4e775c7

Browse files
committed
add transform for {"Bounty", CommandResponse}
1 parent 234589a commit 4e775c7

File tree

3 files changed

+32
-13
lines changed

3 files changed

+32
-13
lines changed

scripts/database_migration.exs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ defmodule DatabaseMigration do
3030
alias Algora.Payments.Customer
3131
alias Algora.Payments.PaymentMethod
3232
alias Algora.Payments.Transaction
33+
alias Algora.Workspace.CommandResponse
3334
alias Algora.Workspace.Installation
3435
alias Algora.Workspace.Ticket
3536

@@ -45,6 +46,7 @@ defmodule DatabaseMigration do
4546
{"GithubIssue", nil},
4647
{"GithubPullRequest", nil},
4748
{"Bounty", Bounty},
49+
{"Bounty", CommandResponse},
4850
{"Reward", nil},
4951
{"Attempt", Attempt},
5052
{"Claim", Claim},
@@ -338,6 +340,23 @@ defmodule DatabaseMigration do
338340
}
339341
end
340342

343+
defp transform({"Bounty", CommandResponse}, row, _db) do
344+
if row["github_res_comment_id"] != nil do
345+
%{
346+
"id" => row["id"],
347+
"provider" => "github",
348+
"provider_meta" => nil,
349+
"provider_command_id" => row["github_req_comment_id"],
350+
"provider_response_id" => row["github_res_comment_id"],
351+
"command_source" => "comment",
352+
"command_type" => "bounty",
353+
"ticket_id" => row["task_id"],
354+
"inserted_at" => row["created_at"],
355+
"updated_at" => row["updated_at"]
356+
}
357+
end
358+
end
359+
341360
defp transform({"Attempt", Attempt}, row, db) do
342361
bounty = db |> Map.get("Bounty", []) |> Enum.find(&(&1["id"] == row["bounty_id"]))
343362

@@ -740,7 +759,7 @@ defmodule DatabaseMigration do
740759
|> Map.take(Enum.map(Map.keys(default_fields), &Atom.to_string/1))
741760
|> Map.new(fn {k, v} -> {String.to_existing_atom(k), v} end)
742761

743-
# Ensure handle is unique
762+
# TODO: do we need this?
744763
fields = ensure_unique_handle(fields)
745764

746765
Map.merge(default_fields, fields)

scripts/v1-progress.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
- org_id: 1
7373
- task_id: 1
7474
- status: 0
75-
- github_req_comment_id: 0
76-
- github_res_comment_id: 0
75+
- github_req_comment_id: 1
76+
- github_res_comment_id: 1
7777
- type: 0
7878
- kind: 0
7979
- visibility: 0

scripts/v2-progress.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@
5454
- inserted_at: 1
5555
- updated_at: 1
5656
- command_responses:
57-
- id: 0
58-
- provider: 0
59-
- provider_meta: 0
60-
- provider_command_id: 0
61-
- provider_response_id: 0
62-
- command_source: 0
63-
- command_type: 0
64-
- ticket_id: 0
65-
- inserted_at: 0
66-
- updated_at: 0
57+
- id: 1
58+
- provider: 1
59+
- provider_meta: -1
60+
- provider_command_id: 1
61+
- provider_response_id: 1
62+
- command_source: 1
63+
- command_type: 1
64+
- ticket_id: 1
65+
- inserted_at: 1
66+
- updated_at: 1
6767
- comment_cursors:
6868
- id: -1
6969
- provider: -1

0 commit comments

Comments
 (0)