Skip to content

Commit e0fff5c

Browse files
committed
update unique constraint
1 parent 0c406c4 commit e0fff5c

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

lib/algora/bounties/jobs/notify_bounty.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ defmodule Algora.Bounties.Jobs.NotifyBounty do
8787
end
8888

8989
defp ensure_command_response(token, ticket_ref, command_id, command_source, ticket, body) do
90-
case Workspace.fetch_command_response("github", command_id, command_source) do
90+
case Workspace.fetch_command_response(ticket.id, :bounty) do
9191
{:ok, response} ->
9292
case Github.update_issue_comment(
9393
token,

lib/algora/workspace/workspace.ex

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,11 @@ defmodule Algora.Workspace do
155155
Repo.all(from(i in Installation, where: i.owner_id == ^user_id, preload: [:connected_user]))
156156
end
157157

158-
def fetch_command_response(provider, command_id, command_source) do
158+
def fetch_command_response(ticket_id, command_type) do
159159
Repo.fetch_one(
160160
from cr in CommandResponse,
161-
where: cr.provider == ^provider,
162-
where: cr.provider_command_id == ^to_string(command_id),
163-
where: cr.command_source == ^command_source
161+
where: cr.ticket_id == ^ticket_id,
162+
where: cr.command_type == ^command_type
164163
)
165164
end
166165

priv/repo/migrations/20250125160156_create_command_responses.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ defmodule Algora.Repo.Migrations.CreateCommandResponses do
1414
timestamps()
1515
end
1616

17-
create unique_index(:command_responses, [:provider, :provider_command_id, :command_source])
18-
create index(:command_responses, [:ticket_id])
17+
create unique_index(:command_responses, [:ticket_id, :command_type])
1918
end
2019
end

0 commit comments

Comments
 (0)