-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Hide dashboard import icons when redundant #2 #5102
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -192,10 +192,7 @@ defmodule PlausibleWeb.Api.StatsController do | |
|
||
params = realtime_period_to_30m(params) | ||
|
||
query = | ||
site | ||
|> Query.from(params, debug_metadata(conn)) | ||
|> Query.set_include(:imports_meta, true) | ||
query = Query.from(site, params, debug_metadata(conn)) | ||
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. One of the changes in #5097 was to provide the default "previous_period" comparison to the query here (instead of I think that's still required - Top Stats are always queried with a comparison option, however,
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. The business logic changes you are describing in this and other comments are pretty complicated, non-intuitive and seem contradictory to what we discussed in the call. Is there a ticket somewhere with the full context? I don't see why the frontend change is at all necessary here to fix the 'bug' that including comparison query in meta.include_imported added but I'm likely missing something. Here's what I've got based on your original PR description: Bug description User opens dashboard for month of March. User has imported data in february (but none in march) Expected result: Imports button should say "Click to include imported data" 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.
There's no ticket at the moment, as it seemed to me like a niche thing to get out of the way with a single PR. Should we create one?
The "bug" here is not very straight forward indeed as the desired behaviours are somewhat conflicting. The Top Stats query currently serves another purpose in addition to simply aggregating the stats. It is to set the state of whether imported data is currently visible on the dashboard or not, AND whether it exists at all in the given query (with comparison) range. From the API perspective, I wouldn't even say there's a bug - imported data is in the Top Stats comparison range so the request responds with:
The issue/weirdness comes from the fact that we're not in the "comparison mode" and yet the backend ends up running a comparison query because Top Stats fetches comparisons even when not in comparison mode - that is to render the small change percentages with arrows. The desired behaviour (as pointed out by Marko) is that when we're not explicitly in comparison mode, the top stats comparison range should "silently" count imported data. The issue at hand could theoretically be solved by:
None of these solutions is perfect in my head. Also, I believe this issue was there already before any imports-related work/refactoring that was part of the scroll depth project. |
||
|
||
%{ | ||
top_stats: top_stats, | ||
|
@@ -220,18 +217,19 @@ defmodule PlausibleWeb.Api.StatsController do | |
end | ||
|
||
defp with_imported_switch_info(%Jason.OrderedObject{} = meta) do | ||
case {meta[:imports_included], meta[:imports_skip_reason]} do | ||
{true, nil} -> | ||
%{visible: true, togglable: true, tooltip_msg: "Click to exclude imported data"} | ||
|
||
{false, nil} -> | ||
%{visible: true, togglable: true, tooltip_msg: "Click to include imported data"} | ||
|
||
{false, :unsupported_query} -> | ||
case Map.new(meta) do | ||
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. There's one case missing here: %{imports_included_for_main_query: false, imports_included: true} ->
%{visible: true, togglable: true, tooltip_msg: "Click to exclude imported data"} When imports were included only in comparison range, it still means that imports were included, and the tooltip should say "click to exclude". |
||
%{imports_included: false, imports_skip_reason: :unsupported_query} -> | ||
%{visible: true, togglable: false, tooltip_msg: "Imported data cannot be included"} | ||
|
||
{false, reason} when reason in [:no_imported_data, :out_of_range] -> | ||
%{imports_included: false, imports_skip_reason: reason} | ||
when reason in [:no_imported_data, :out_of_range] -> | ||
%{visible: false, togglable: false, tooltip_msg: nil} | ||
|
||
%{imports_included_for_main_query: true} -> | ||
%{visible: true, togglable: true, tooltip_msg: "Click to exclude imported data"} | ||
|
||
%{imports_included_for_main_query: false} -> | ||
%{visible: true, togglable: true, tooltip_msg: "Click to include imported data"} | ||
end | ||
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.
How about getting rid of
comparison_utc_time_range
? That information might as well be included under thecomparison_query
itself.