Closed Bug 1467401 Opened 6 years ago Closed 6 years ago

Convert lodash .groupBy() to native ES6 JS

Categories

(Tree Management :: Treeherder: Frontend, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: evct, Assigned: evct)

References

Details

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36 OPR/53.0.2907.68 Steps to reproduce: Converting all _.groupBy() (lodash) functions to native .filter() (ES6 JS)
Assignee: nobody → oss
Blocks: 1466494
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Priority: -- → P3
Attachment #8984092 - Flags: review?(cdawson)
Typo in my original comment: "Converting all _.groupBy() (lodash) functions to native ES6 JS". (I don't know how to edit comment)
Unfortunately Bugzilla doesn't support editing comments at the moment (bug 540) - the typo doesn't matter too much since it's mainly the bug title and PR/commit titles that will be read. Unrelated, but myself and Cameron have this Bugzilla component in our watch list, so adding the CCs isn't needed, if you'd rather save time by skipping that step :-)
Ok thanks for the information, and I will skip this step in the future
Attachment #8984092 - Flags: review?(cdawson) → review+
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
When I visit stage (https://treeherder.allizom.org/#/jobs?repo=mozilla-inbound) I get: TypeError: "R.repos is undefined" getOrderedRepoGroups https://treeherder.allizom.org/index.593ea103062eb159bdc8.bundle.js:31:7795 fn https://treeherder.allizom.org/vendor.bf21b3a1381cc2dcd328.bundle.js line 45 > Function:4:153 ... ...which I think is from: https://github.com/mozilla/treeherder/commit/899396651714e9454946396ecd124db128fabc8d#diff-46e683ff6ffab8c2ca1bdf9d1bd2bb00R36 The ES6 equivalent for _.groupBy() is also pretty verbose. I'm wondering if we should leave that one as is for now, or even see if we can adjust the repo groups data structure so it doesn't need such transformation?
Status: RESOLVED → REOPENED
Flags: needinfo?(cdawson)
Resolution: FIXED → ---
Ok I totally missed this error but indeed I'm having the same behavior on my side... Looking into it. I'm not used to the code base and the various data structure of Treeherder yet, but that may be a good idea.
In fact `$rootScope.repos` is not filled instantly (slight loading delay I guess), so the very first calls of `getOrderedRepoGroups()` won't do anything since `$rootScope.repos` will be set as undefined. Then the next calls of getOrderedRepoGroups() actually work because `$rootScope.repos` has been filled with the repos. _.groupBy() ignored this case, while the ES6 equivalent I wrote fails if the collection on which we apply .reduce() is undefined. A possible solution could be to first check if `$rootScope.repos` is not undefined. I can submit a patch if it's ok with you.
Dang, my sincere apologies for not catching this. I must have neglected to have the console window open when testing this. Ed's point about restructuring the repos structure. I'm happy to look into doing this when I convert the nav bars to React. I'll revert this for now.
Flags: needinfo?(cdawson)
Depends on: 1468533
Comment on attachment 8984698 [details] Link to GitHub pull-request: https://github.com/mozilla/treeherder/pull/3643 (Obsoleting since bug 1468533 is taking a different approach)
Attachment #8984698 - Attachment is obsolete: true
Status: REOPENED → RESOLVED
Closed: 6 years ago6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: