-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Include linked policy name with report summary name #10311
Comments
Are we sure we want to do that? We would be sending the same data over and over again (once per report) and allegedly, any policy you have access to, you should have the summary loaded in newDot, so we could display the correct name by looking it up in the policy summary data. |
I agree with @iwiznia. Can we just look up the policy name without sending a request to the server? We should have this data loaded in the client already! |
I agree this would denormalize our data, but I guess one could argue having to lookup the policy name is "data massaging". I don't feel too strongly either way. @tgolen thoughts? |
Exactly this, yes. It is the definition of data massaging which is against everything we've been working towards with this new API.
Is there a problem with this? |
Hmm I'm not suggesting doing this in the API call. We already have the data since we fetched the policies in OpenApp. Maybe I'm missing something, but why wouldn't |
Why would it be massaging the data? It is just reading it from a different source, not modifying it.
Not per se, but why would we return data we already know we have? |
Right now, this page requires two separate API calls to get all the data needed for display. That is not 1:1, that is 1:2 and I think that's wrong. I would feel a little bit better if the Onyx connection was only connecting to the single policyID key that it needs to get the name, but currently, it's connecting to the entire collection of policies, and looping through all of them to find the right policy ID. This sounds similar to what @luacmartins is proposing, but it still breaks the 1:1 rule. |
Not sure why it would break 1:1, since the policies are fetched on OpenApp and we don't need to trigger an additional API call for it.
We would need to connect to the entire collection, but we don't need to loop through all of it to find the right policy, we could just access it directly by |
Exactly. There must be tons of places where we assume the data we loaded during OpenApp is there and load additional data for a specific page, no? |
Yea, we will either fetch additional data like we do in the |
Why do you need to connect to the entire collection? You should be able to connect to the collection's policy key directly, can't you?
Regarding 1:1; If you are on the workspace settings page, and you refresh the page, you would count 2 API requests for one action, no? How is that not 1:2? |
I don't think we get passed
Well that happens right now. Refresh your app with an open report and notice a call to both |
Well, once this happens, the report is in the props that are passed to Maybe we don't have logic built to handle this, and I honestly don't know what would happen, but it's worth trying (and supporting):
and if the key returns |
Yea, it doesn't seem like we support that yet. These are the props available in this call: One thing that I noticed is that policy is already available, because we pass it from withFullPolicy and connecting to it again seems useless. |
I can give this a try. EDIT: doesn't work unfortunately. I think report has to be passed down from the parent component
withFullPolicy is added incorrectly here. It connects the policy based on the policy ID in the route however there is none for this page so it doesn't work. We'll be removing it from this page with the GetFullPolicy refactor soon. |
One solution could be to update Otherwise we'd have to update our Auth command for report summaries to join on |
I'd be interested to see what you tried, because I still think this would be possible to get it to work, but it would require a change to
I think this is really what we should be doing in the first place. This is the precedent and the best practice. Anything else is just a hack, and a complex one of that. If we keep trying to do this on the front-end, then that basically cements this rule in place:
|
This is not correct, it just requires the policy summaries, which are loaded on first load and always there. |
Well, I did not specify what policy objects I was referring to. But my concern still stands: it requests having a FULL list of policy summaries updated on the client |
Yes, which we always will have. |
I've got around to drafting SQL query changes for SELECT
...
JSON_EXTRACT(nvps.value, '$.name') policyName
FROM
...
LEFT JOIN nameValuePairs nvps ON nvps.name = 'expensify_policy' || JSON_EXTRACT(rnvps.rNVPs, '$.expensify_policyID'); However, it sounds like we're divided on whether a join across datasets on the frontend (even a simple one like what we've talked about) qualifies as data massaging so I'm gonna start a discussion in #N7 on it to hopefully get some consensus. |
I still think we should not be sending this data back and should get it from the already loaded policy summaries that we know will always be loaded |
After our discussion on data massaging here it sounds like this specific issue isn't too big of a problem so I'll close this out. However, it would be nice to have some functionality in Onyx to clean up this behavior for joining keys so I created a follow up issue for that here. |
Problem
Per this Google Doc convo, some report pages including the
ReportSettingsPage
need the name of the linked policy, but this data is not included with report data provided by the API so it needs to be searched on the client.Solution
Include linked policy name with report summary data and remove logic for looking up the policy name in
ReportSettingsPage
.The text was updated successfully, but these errors were encountered: