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

[HOLD for payment 2024-04-03] [Report Fields] [Onyx] Move policyReportFields_ key back into the policy_ key #36170

Closed
flodnv opened this issue Feb 8, 2024 · 38 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Engineering Internal Requires API changes or must be handled by Expensify staff Task Weekly KSv2

Comments

@flodnv
Copy link
Contributor

flodnv commented Feb 8, 2024

Problem & Solution

Sister issue: #36171

Discussed internally, summarised here and concluded there

  • We added the onyx keys policyTaxRates_ and policyReportFields_ for no good reason. There's no size to optimize for in these collections.
  • This makes my life harder in trying to fix an architectural problem of sending policy updates in https://github.com/Expensify/Auth/pull/9773 (see https://expensify.slack.com/archives/C03TQ48KC/p1706285244529629 & [Backwards Compatibility] [HIGH] Push all policy updates to all policy members forever #34834)
  • This makes code more complex than it needs to be (lots of existing data massaging for really no gain)
  • As such, we should kill and fix this unnecessarily complex code that was recently introduced. This means, at a minimum (I might be missing things):
    • Moving this data back into the policy_ key
    • Removing any data massaging from the backend
    • Have the frontend accept the same data as what's in the database
    • Where we should not display disabled fields, then let's use the disabled property to hide them. We will need to display them to admins soon enough
  • No need to worry about sending updates to policy members when the policy changes, that will be done as part of https://github.com/Expensify/Auth/pull/9773, which includes doing this for all current and future policy attributes

cc @iwiznia @puneetlath @tgolen @marcaaron @francoisl @dangrous @johnmlee101 @MonilBhavsar

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~010e62ab2c798627fa
  • Upwork Job ID: 1755672881949298688
  • Last Price Increase: 2024-02-08
@flodnv flodnv added Engineering Daily KSv2 Internal Requires API changes or must be handled by Expensify staff Task labels Feb 8, 2024
Copy link

melvin-bot bot commented Feb 8, 2024

Job added to Upwork: https://www.upwork.com/jobs/~010e62ab2c798627fa

Copy link

melvin-bot bot commented Feb 8, 2024

Triggered auto assignment to Contributor Plus for review of internal employee PR - @mollfpr (Internal)

@thienlnam
Copy link
Contributor

Sibtain will be handling the FE changes and I will take the BE changes

@marcaaron
Copy link
Contributor

I am not aware of any documented problem with storing everything related to a policy in the policy_ key.

Some hypothetical problems to watch out for could be:

  • Large policy JSON is inefficient to modify in Onyx because we do a deep merge (maybe some copying still happens in some places as well).
  • Optimizations exist to deep compare to see if we should update subscribers. Larger the JSON the slower these comparisons would be.
  • Subscribing to a subset of data should result in faster updates than subscribing to a large JSON object. Even with the use of a selector. I think it would still be faster.

That's all I have to say on it though. I have not instrumented any of that and it's all just theoretical. This proposal looks fine.

@flodnv
Copy link
Contributor Author

flodnv commented Feb 9, 2024

Large policy JSON is inefficient to modify in Onyx

How large? Tags is the most bloating data and it's already in its own key (and for now we'll leave it there)

because we do a deep merge

Can you expand on "we do a deep merge"? Where and why?


Thanks for having a look and commenting 🙇

@marcaaron
Copy link
Contributor

How large? Tags is the most bloating data and it's already in its own key (and for now we'll leave it there)

I haven't instrumented anything so I can't answer that question.

Can you expand on "we do a deep merge"? Where and why?

There is a memory cache layer. Before we save things to the Onyx dbs we merge them into the existing objects in the cache. The smaller those objects are the faster they would be to merge (hypothetically). I am not aware that we've hit any kind of limit there yet - but I do know that it was slow enough in the past that we optimized it to make it faster. We could have someone instrument to see at what point the merges get slow - maybe it's a lot or not.

@melvin-bot melvin-bot bot added the Overdue label Feb 12, 2024
Copy link

melvin-bot bot commented Feb 12, 2024

@allroundexperts, @thienlnam Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@allroundexperts
Copy link
Contributor

Will have a PR ready by tomorrow Melv.

@melvin-bot melvin-bot bot removed the Overdue label Feb 12, 2024
@allroundexperts
Copy link
Contributor

Update: Still working on a PR. Taking me longer than I expected. Will provide an update tomorrow.

@thienlnam
Copy link
Contributor

No worries, I'll still need to fold the reportField back into the policy_ key on the back-end. I'm currently working on those pusher updates for modifying an existing report field / new endpoint for removing a field

@allroundexperts
Copy link
Contributor

Created draft PR #36553. Please let me know once the backend changes are done and I'll then record the videos.

@melvin-bot melvin-bot bot added the Overdue label Feb 19, 2024
Copy link

melvin-bot bot commented Feb 20, 2024

@allroundexperts, @thienlnam Huh... This is 4 days overdue. Who can take care of this?

@thienlnam
Copy link
Contributor

Still haven't had the chance to add the BE changes as I'm focused on Track, likely will get to it later this week

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Feb 21, 2024
@thienlnam
Copy link
Contributor

Back-end PR is in review, as part of simplifying the changes I've made a few additional changes that will need to be reflected in the FE PR

  • Report fields are now listed under the 'fieldList' key in the policy and the report
  • We're now going to return all the keys on the field list item, that being said we'll need to now have a way on the FE to get the valid options (Removing keys from the values, where disabledOptions are true), and the types upgraded
  • The report fields will be returned keyed with expensify_ so we can remove the changes I added here
        {
            "type": "formula",
            "fieldID": "text_title",
            "defaultValue": "{report:type} {report:startdate}",
            "value": null,
            "name": "title",
            "target": "expense",
            "values": [],
            "keys": [],
            "externalIDs": [],
            "disabledOptions": [],
            "externalID": null,
            "orderWeight": 0,
            "deletable": true,
            "origin": null,
            "isTax": false,
            "defaultExternalID": null
        },
   {
            "type": "dropdown",
            "fieldID": "field_id_NUGGET_SHOPZ",
            "defaultValue": "",
            "value": null,
            "name": "Nugget Shopz",
            "target": "expense",
            "values": [
                "Booger King",
                "Chick Fill Hay",
                "Kay Eff See",
                "Mickey Dee's",
                "Wendeez"
            ],
            "keys": [],
            "externalIDs": [],
            "disabledOptions": [
                false,
                false,
                false,
                false,
                false
            ],
            "externalID": null,
            "orderWeight": 1,
            "deletable": false,
            "origin": null,
            "isTax": false,
            "defaultExternalID": ""
        }

@thienlnam
Copy link
Contributor

The last Auth PR was merged and should be getting deployed on Monday - once that is done, we can merge @allroundexperts's App PR here #36553

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Mar 15, 2024
@JmillsExpensify
Copy link

Auth PR was deployed today, so looks like we need to get @allroundexperts PR into review. When do we expect that to happen?

Copy link

melvin-bot bot commented Mar 19, 2024

@allroundexperts, @thienlnam Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 Overdue labels Mar 20, 2024
@allroundexperts
Copy link
Contributor

@thienlnam @JmillsExpensify PR ready for review!

@JmillsExpensify
Copy link

Thank you!

@jjcoffee
Copy link
Contributor

@JmillsExpensify Could you assign me here as I reviewed the PR? Thanks! 🙇

@JmillsExpensify
Copy link

Done. I'll go ahead and assign myself for the payment later.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Mar 27, 2024
@melvin-bot melvin-bot bot changed the title [Report Fields] [Onyx] Move policyReportFields_ key back into the policy_ key [HOLD for payment 2024-04-03] [Report Fields] [Onyx] Move policyReportFields_ key back into the policy_ key Mar 27, 2024
Copy link

melvin-bot bot commented Mar 27, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Mar 27, 2024
Copy link

melvin-bot bot commented Mar 27, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.56-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-04-03. 🎊

For reference, here are some details about the assignees on this issue:

@JmillsExpensify
Copy link

Payment summary:

@jjcoffee Do we need any regression tests for this issue?

@JmillsExpensify
Copy link

Upwork offer sent to C+

@jjcoffee
Copy link
Contributor

jjcoffee commented Apr 3, 2024

@JmillsExpensify Accepted, thanks! There should already be regression tests that cover the report fields functionality, so I think we're good here.

@JmillsExpensify
Copy link

Awesome! Contract paid, so closing this issue.

@github-project-automation github-project-automation bot moved this from Release 1: Spring 2024 (May) to Done in [#whatsnext] #expense Apr 3, 2024
@laurenreidexpensify
Copy link
Contributor

Payment summary:

@JmillsExpensify
Copy link

$500 approved for @allroundexperts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Engineering Internal Requires API changes or must be handled by Expensify staff Task Weekly KSv2
Projects
Status: Done
Development

No branches or pull requests

8 participants