Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
When requesting the most recent command, exclude retry
Browse files Browse the repository at this point in the history
Otherwise, retrying a retry will cause an infinite loop, either:

Resolves https://forum.bors.tech/t/bors-sometimes-doesnt-see-retry-messages-until-a-ping/278
  • Loading branch information
notriddle committed Jan 30, 2019
1 parent b014de3 commit 1fb46cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/database/context/logging.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule BorsNG.Database.Context.Logging do
@spec most_recent_cmd(Patch.t) :: {User.t, BorsNG.Command.cmd} | nil
def most_recent_cmd(%Patch{id: id}) do
from(l in Log)
|> where([l], l.patch_id == ^id)
|> where([l], l.patch_id == ^id and l.cmd != ^:retry)
|> order_by([l], [desc: l.updated_at, desc: l.id])
|> preload([l], :user)
|> limit(1)
Expand Down
8 changes: 8 additions & 0 deletions test/context/logging_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,12 @@ defmodule BorsNG.Database.Context.LoggingTest do
user_id = user.id
assert {%User{id: ^user_id}, :cmd2} = Logging.most_recent_cmd(patch)
end

test "most recent command should exclude retry", params do
%{patch: patch, user: user} = params
Logging.log_cmd(patch, user, :cmd1)
Logging.log_cmd(patch, user, :retry)
user_id = user.id
assert {%User{id: ^user_id}, :cmd1} = Logging.most_recent_cmd(patch)
end
end

0 comments on commit 1fb46cb

Please sign in to comment.