Skip to content

Commit 6a24ac0

Browse files
committed
in midst of getting migration script up to date
1 parent b24a15a commit 6a24ac0

File tree

1 file changed

+43
-25
lines changed

1 file changed

+43
-25
lines changed

scripts/database_migration.exs

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,35 +66,53 @@ defmodule DatabaseMigration do
6666
row =
6767
cond do
6868
github_issue ->
69-
row
70-
|> Map.put("type", "issue")
71-
|> Map.put("title", github_issue["title"])
72-
|> Map.put("description", github_issue["body"])
73-
|> Map.put("inserted_at", github_issue["created_at"])
74-
|> Map.put("updated_at", github_issue["updated_at"])
75-
|> Map.put("url", github_issue["html_url"])
76-
|> Map.put("provider", "github")
77-
|> Map.put("provider_id", github_issue["id"])
78-
|> Map.put("provider_meta", deserialize_value(github_issue))
69+
%{
70+
"id" => row["id"],
71+
"provider" => "github",
72+
"provider_id" => github_issue["id"],
73+
"provider_meta" => deserialize_value(github_issue),
74+
"type" => "issue",
75+
"title" => github_issue["title"],
76+
"description" => github_issue["body"],
77+
"number" => github_issue["number"],
78+
"url" => github_issue["html_url"],
79+
"inserted_at" => github_issue["created_at"],
80+
"updated_at" => github_issue["updated_at"]
81+
}
7982

8083
github_pull_request ->
81-
row
82-
|> Map.put("type", "pull_request")
83-
|> Map.put("title", github_pull_request["title"])
84-
|> Map.put("description", github_pull_request["body"])
85-
|> Map.put("inserted_at", github_pull_request["created_at"])
86-
|> Map.put("updated_at", github_pull_request["updated_at"])
87-
|> Map.put("url", github_pull_request["html_url"])
88-
|> Map.put("provider", "github")
89-
|> Map.put("provider_id", github_pull_request["id"])
90-
|> Map.put("provider_meta", deserialize_value(github_pull_request))
84+
%{
85+
"id" => row["id"],
86+
"provider" => "github",
87+
"provider_id" => github_pull_request["id"],
88+
"provider_meta" => deserialize_value(github_pull_request),
89+
"type" => "pull_request",
90+
"title" => github_pull_request["title"],
91+
"description" => github_pull_request["body"],
92+
"number" => github_pull_request["number"],
93+
"url" => github_pull_request["html_url"],
94+
"inserted_at" => github_pull_request["created_at"],
95+
"updated_at" => github_pull_request["updated_at"]
96+
}
9197

9298
true ->
93-
row
94-
# TODO: maybe discard altogther?
95-
|> Map.put("url", "https://github.com/#{row["repo_owner"]}/#{row["repo_name"]}/issues/#{row["number"]}")
96-
|> Map.put("inserted_at", "1970-01-01 00:00:00")
97-
|> Map.put("updated_at", "1970-01-01 00:00:00")
99+
if row["forge"] != "github" do
100+
raise "Unknown forge: #{row["forge"]}"
101+
end
102+
103+
%{
104+
"id" => row["id"],
105+
"provider" => row["forge"],
106+
"provider_id" => nil,
107+
"provider_meta" => nil,
108+
"type" => "issue",
109+
"title" => row["title"],
110+
"description" => row["body"],
111+
"number" => row["number"],
112+
"url" => "https://github.com/#{row["repo_owner"]}/#{row["repo_name"]}/issues/#{row["number"]}",
113+
"inserted_at" => row["created_at"],
114+
"updated_at" => row["updated_at"]
115+
}
98116
end
99117

100118
row

0 commit comments

Comments
 (0)