You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2024-11-11] [250] Use general-purpose memoization lib in Localize #50194
We have built a general-purpose memoziation lib and standardized on using it as a best practice for consistency. However, in src/libs/Localize we still have a different custom memoization/cache implementation.
Solution
Refactor src/libs/Localize to use the general-purpose memoization lib
Please re-state the problem that we are trying to solve in this issue.
utils/Localize still uses it's own memoization implementation using translationCache function which is not in alignment with the best practice since all/most? other places are using utils/memoize
What is the root cause of that problem?
Just a refactor that was left behind and needs to be done
What changes do you think we should make in order to solve the problem?
Since utils/memoize is just wrapping a function with memoization layer and returning the memoized value,
I can make the the refactor here if you want to make sure it works and won't create any unwanted behavior. I'll also backfill a unit test in LocalizeTests.ts for checking the memoization actually works unless you think that's extra.
What alternative solutions did you explore? (Optional)
Since we already have a utility function that we specifically want to use, no alternative solution is explored.
changed the title [-][250] Use general-purpose memoization lib in Localize[/-][+][HOLD for payment 2024-11-11] [250] Use general-purpose memoization lib in Localize[/+]on Nov 4, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.56-9 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@hoangzinh / @shubham1206agra@abekkala The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
[Contributor] Classify the bug: It's not a bug issue, it's a refactoring issue
Bug classification
Source of bug:
1a. Result of the original design (eg. a case wasn't considered)
1b. Mistake during implementation
1c. Backend bug
[x ] 1z. Other:
Where bug was reported:
2a. Reported on production
2b. Reported on staging (deploy blocker)
2c. Reported on a PR
2z. Other:
Who reported the bug:
3a. Expensify user
3b. Expensify employee
3c. Contributor
3d. QA
3z. Other:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: N/A
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
No, we don't need a regression test for this issue. It's already covered somewhere
Activity
melvin-bot commentedon Oct 3, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh (
External)roryabraham commentedon Oct 3, 2024
cc @kacper-mikolajczak
melvin-bot commentedon Oct 3, 2024
Triggered auto assignment to @abekkala (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.shijir0927 commentedon Oct 4, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
utils/Localizestill uses it's own memoization implementation usingtranslationCachefunction which is not in alignment with the best practice since all/most? other places are usingutils/memoizeWhat is the root cause of that problem?
Just a refactor that was left behind and needs to be done
What changes do you think we should make in order to solve the problem?
Since
utils/memoizeis just wrapping a function with memoization layer and returning the memoized value,In
utils/LocalizegetTranslatedPhrase()function, we can get rid of the logic that is manually setting and checking the phrase in a map which makes the functiontranslationCache()obselete.https://github.com/Expensify/App/blob/821edc51788b616e323cae0dc00f4b0aa7246766/src/libs/Localize/index.ts#L89C1-L99C6
Use the new memoize utility function wrapping the
getTranslatedPhrase()valuehttps://github.com/Expensify/App/blob/821edc51788b616e323cae0dc00f4b0aa7246766/src/libs/Localize/index.ts#L171C1-L177C103
I can make the the refactor here if you want to make sure it works and won't create any unwanted behavior. I'll also backfill a unit test in
LocalizeTests.tsfor checking the memoization actually works unless you think that's extra.What alternative solutions did you explore? (Optional)
Since we already have a utility function that we specifically want to use, no alternative solution is explored.
melvin-bot commentedon Oct 4, 2024
shijir0927 commentedon Oct 4, 2024
melvin-bot commentedon Oct 4, 2024
shubham1206agra commentedon Oct 4, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue
Use general-purpose memoization lib in Localize
What is the root cause of that problem?
Feature Request
What changes do you think we should make in order to solve the problem?
We need to cache
getTranslatedPhraseusing memoize present under@libs/memoizemodule.We will use the following code to create memorized function.
And use it in
App/src/libs/Localize/index.ts
Line 177 in 821edc5
And remove the old memoize code present
App/src/libs/Localize/index.ts
Line 63 in 821edc5
Test branch. - https://github.com/shubham1206agra/App/tree/test-localize-memoize
What alternative solutions did you explore? (Optional)
hoangzinh commentedon Oct 4, 2024
@roryabraham just wants to confirm if @kacper-mikolajczak will work on this issue or it's opened for external contributors?
46 remaining items
[-][250] Use general-purpose memoization lib in Localize[/-][+][HOLD for payment 2024-11-11] [250] Use general-purpose memoization lib in Localize[/+]melvin-bot commentedon Nov 4, 2024
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Nov 4, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.56-9 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-11-11. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Nov 4, 2024
@hoangzinh / @shubham1206agra @abekkala The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
abekkala commentedon Nov 5, 2024
PAYMENT SUMMARY FOR NOV 11
please post checklist
hoangzinh commentedon Nov 6, 2024
BugZero Checklist:
Bug classification
Source of bug:
Where bug was reported:
Who reported the bug:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: N/A
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
No, we don't need a regression test for this issue. It's already covered somewhere
melvin-bot commentedon Nov 11, 2024
Payment Summary
Upwork Job
BugZero Checklist (@abekkala)
[HOLD for payment 2024-11-11] [250] Use general-purpose memoization lib in Localize #50194 (comment)
abekkala commentedon Nov 11, 2024
@shubham1206agra can you accept the offer in Upwork? I can then process payment today, thanks!
shubham1206agra commentedon Nov 11, 2024
@abekkala Done
abekkala commentedon Nov 11, 2024
@shubham1206agra payment sent and contract ended - thank you! 🎉
abekkala commentedon Nov 11, 2024
PAYMENT SUMMARY FOR NOV 11
garrettmknight commentedon Nov 13, 2024
$250 approved for @hoangzinh