-
-
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: Find Options - Update components API #552
base: main
Are you sure you want to change the base?
Changes from all commits
fbae50f
7d69b01
dd34146
c87cc06
d781520
3be4f8c
a3bb101
aae96e4
7f3c862
fc88454
6d3d13e
66223fa
38f794c
43a436f
c07ead1
c459af2
4482397
b0ed9e5
cc4856b
8882b17
ed8828e
562c90a
e487ad3
5b41729
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -46,7 +46,7 @@ defmodule ApplicationRunner.Environment.QueryServer do | |||||
Swarm.join(group, pid) | ||||||
end | ||||||
|
||||||
def get_data(env_id, coll, query_parsed, projection) do | ||||||
def get_data(env_id, coll, query_parsed, projection, options) do | ||||||
GenServer.call(get_full_name({env_id, coll, query_parsed}), {:get_data, projection}) | ||||||
end | ||||||
|
||||||
|
@@ -64,8 +64,9 @@ defmodule ApplicationRunner.Environment.QueryServer do | |||||
{:ok, coll} <- Keyword.fetch(opts, :coll), | ||||||
{:ok, query_transformed} <- Keyword.fetch(opts, :query_transformed), | ||||||
{:ok, query_parsed} <- Keyword.fetch(opts, :query_parsed), | ||||||
{:ok, data} <- fetch_initial_data(env_id, coll, query_transformed), | ||||||
{:ok, projection} <- Keyword.fetch(opts, :projection) do | ||||||
{:ok, projection} <- Keyword.fetch(opts, :projection), | ||||||
{:ok, options} <- Keyword.fetch(opts, :options), | ||||||
{:ok, data} <- fetch_initial_data(env_id, coll, query_transformed, projection, options) do | ||||||
projection_data = | ||||||
if projection != %{} do | ||||||
%{projection => projection_data(data, projection)} | ||||||
|
@@ -83,7 +84,8 @@ defmodule ApplicationRunner.Environment.QueryServer do | |||||
latest_timestamp: Mongo.timestamp(DateTime.utc_now()), | ||||||
done_ids: MapSet.new(), | ||||||
w_pids: MapSet.new(), | ||||||
projection_data: projection_data | ||||||
projection_data: projection_data, | ||||||
options: options | ||||||
}} | ||||||
else | ||||||
:error -> | ||||||
|
@@ -119,20 +121,27 @@ defmodule ApplicationRunner.Environment.QueryServer do | |||||
Map.values(map_data) | ||||||
end | ||||||
|
||||||
defp fetch_initial_data(_env_id, coll, query_transformed) | ||||||
defp fetch_initial_data(_env_id, coll, query_transformed, projection, options) | ||||||
when is_nil(coll) or is_nil(query_transformed) do | ||||||
Logger.debug("#{__MODULE__} fetch_initial_data with nil query") | ||||||
|
||||||
{:ok, []} | ||||||
end | ||||||
|
||||||
defp fetch_initial_data(env_id, coll, query_transformed) do | ||||||
defp fetch_initial_data(env_id, coll, query_transformed, projection, options) do | ||||||
Logger.debug("#{__MODULE__} fetch_initial_data with data: #{inspect([env_id, coll, query_transformed])}") | ||||||
|
||||||
mongo_opts = | ||||||
Keyword.merge( | ||||||
[projection: projection], | ||||||
Enum.map(options, fn {k, v} -> {String.to_atom(k), v} end) | ||||||
) | ||||||
|
||||||
MongoInstance.run_mongo_task(env_id, MongoStorage, :filter_docs, [ | ||||||
env_id, | ||||||
coll, | ||||||
query_transformed | ||||||
query_transformed, | ||||||
mongo_opts | ||||||
]) | ||||||
end | ||||||
|
||||||
|
@@ -418,14 +427,14 @@ defmodule ApplicationRunner.Environment.QueryServer do | |||||
if projection_change?(projection_data, new_data, k) do | ||||||
{k, v} | ||||||
else | ||||||
group = ViewServer.group_name(env_id, coll, query_parsed, k) | ||||||
group = ViewServer.group_name(env_id, coll, query_parsed, k, %{}) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modification not needed:
Suggested change
|
||||||
Swarm.publish(group, {:data_changed, projection_data(new_data, k)}) | ||||||
{k, projection_data(new_data, k)} | ||||||
end | ||||||
end) | ||||||
|
||||||
# Notify ViewServer with no projection. | ||||||
group = ViewServer.group_name(env_id, coll, query_parsed, %{}) | ||||||
group = ViewServer.group_name(env_id, coll, query_parsed, %{}, %{}) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same:
Suggested change
|
||||||
Swarm.publish(group, {:data_changed, new_data}) | ||||||
|
||||||
new_projection_data | ||||||
|
@@ -441,11 +450,11 @@ defmodule ApplicationRunner.Environment.QueryServer do | |||||
} | ||||||
) do | ||||||
Enum.each(Map.keys(projection_data), fn projection_key -> | ||||||
group = ViewServer.group_name(env_id, old_coll, query_parsed, projection_key) | ||||||
group = ViewServer.group_name(env_id, old_coll, query_parsed, projection_key, %{}) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same:
Suggested change
|
||||||
Swarm.publish(group, {:coll_changed, new_coll}) | ||||||
end) | ||||||
|
||||||
group = ViewServer.group_name(env_id, old_coll, query_parsed, %{}) | ||||||
group = ViewServer.group_name(env_id, old_coll, query_parsed, %{}, %{}) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same:
Suggested change
|
||||||
Swarm.publish(group, {:coll_changed, new_coll}) | ||||||
end | ||||||
|
||||||
|
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.
The initial data should not be fetched with the projections and options since they both should be applied after.
The initial data must stay full to apply the projections and options.
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.
Ok so this PR will need a lot more work to handle each mongo aggregators by hand.
We will start by just implementing the "skip" and "limit" aggregators and we will add more in the future.
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.
Yes. You can create an Epic with the list of the aggregators to manage as we did for the operators