Skip to content
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

fix: speed up Detour queries by returning subsets of JSON snapshot #2946

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

firestack
Copy link
Member

@firestack firestack commented Jan 29, 2025

Comment on lines +103 to +107
|> with_detour()
|> Skate.Detours.Db.Detour.Queries.select_route_name(:route)
|> Skate.Detours.Db.Detour.Queries.select_route_pattern_name(:origin)
|> Skate.Detours.Db.Detour.Queries.select_route_pattern_headsign(:headsign)
|> Skate.Detours.Db.Detour.Queries.select_direction(:direction)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite happy with this, but I wasn't sure about changing the virtual field names. would be happy to discuss though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2948 is why I'm not quite happy with this, as I'm not sure how to hide these functions from the public API while also allowing renaming for situations like this.

Comment on lines +68 to +74
def with_author(query \\ base(), key \\ :author) do
from([detour: d] in query,
join: a in assoc(d, :author),
as: :author,
select_merge: %{^key => a}
)
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: still not certain about this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured out what I'd prefer in #2948

@firestack firestack marked this pull request as ready for review January 29, 2025 16:05
@firestack firestack requested a review from a team as a code owner January 29, 2025 16:05
@firestack firestack requested review from hannahpurcell and bfauble and removed request for a team January 29, 2025 16:05
Copy link
Collaborator

@hannahpurcell hannahpurcell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to learn a little bit about several new things to me (virtual fields and ecto query composition mainly), but I feel like I'm following everything here. It's clean and clear.

The note on with_author, I don't see what could be wrong with it. The note on select_detour_notification_info, I see what you're saying but think what you did is still a solid approach

lib/skate/detours/db/detour.ex Show resolved Hide resolved
lib/skate/detours/db/detour.ex Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants