-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: osi list shows officials' name with email as fallback #137
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ jest.mock("../../../hooks/useSignIns", () => ({ | |
signed_in_at: DateTime.fromISO("2024-07-22T12:45:52.000-04:00", { | ||
zone: "America/New_York", | ||
}), | ||
signed_in_by_user: "[email protected]", | ||
signed_in_by: "[email protected]", | ||
signed_in_employee: EMPLOYEES[0].badge, | ||
}, | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ const TEST_DATA = { | |
{ | ||
rail_line: "blue", | ||
signed_in_at: "2024-07-22T16:42:32Z", | ||
signed_in_by_user: "[email protected]", | ||
signed_in_by: "[email protected]", | ||
signed_in_employee: "123", | ||
}, | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ defmodule OrbitWeb.SignInControllerTest do | |
%{ | ||
"rail_line" => "blue", | ||
"signed_in_at" => _date, | ||
"signed_in_by_user" => _user, | ||
"signed_in_by" => _user, | ||
"signed_in_employee" => _badge | ||
} | ||
] | ||
|
@@ -64,6 +64,47 @@ defmodule OrbitWeb.SignInControllerTest do | |
} = json_response(conn, 200) | ||
end | ||
|
||
@tag :authenticated | ||
test "shows officials' names if available", %{conn: conn} do | ||
insert(:employee, email: "[email protected]") | ||
|
||
insert(:operator_sign_in, | ||
signed_in_at: DateTime.new!(~D[2024-07-21], ~T[12:00:00], @timezone), | ||
signed_in_by_user: build(:user, email: "[email protected]") | ||
) | ||
|
||
conn = get(conn, ~p"/api/signin", %{"line" => "blue", "service_date" => "2024-07-21"}) | ||
|
||
assert %{ | ||
"data" => [ | ||
%{ | ||
"signed_in_by" => "Preferredy Person" | ||
} | ||
] | ||
} = json_response(conn, 200) | ||
end | ||
|
||
@tag :authenticated | ||
test "shows official's email address if name is unavailable", %{conn: conn} do | ||
insert(:operator_sign_in, | ||
signed_in_at: DateTime.new!(~D[2024-07-21], ~T[12:00:00], @timezone), | ||
signed_in_by_user: | ||
build(:user, %{ | ||
email: "[email protected]" | ||
}) | ||
) | ||
|
||
conn = get(conn, ~p"/api/signin", %{"line" => "blue", "service_date" => "2024-07-21"}) | ||
|
||
assert %{ | ||
"data" => [ | ||
%{ | ||
"signed_in_by" => "[email protected]" | ||
} | ||
] | ||
} = json_response(conn, 200) | ||
end | ||
|
||
@tag :authenticated | ||
test "sorted by signed_in_at descending (recent first)", %{conn: conn} do | ||
insert(:operator_sign_in, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (non-blocking): If you're already in here turning the preload for
signed_in_by_user
from the default (which uses a separate query - see here) to using an explicit join in the same query, it might be worth doing the same forsigned_in_employee
, thus turning this whole operation into a single query.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah! thanks, I see you did that in #103. why is that not the default preload behavior, though? I guess because Ecto wants joins to remain explicit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f8ad95b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure - it's also possible that Ecto isn't able to generate the join statements fully programmatically in all cases or something? In any event it's just an interesting quirk to be aware of.