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

Refactor experiment table branch data #4364

Merged
merged 1 commit into from
Jul 27, 2023
Merged

Conversation

mattseddon
Copy link
Member

@mattseddon mattseddon commented Jul 27, 2023

2/2 main <- #4363 <- this

This PR refactors the way that branch data is passed from the extension to the experiments webview. The main reason for the change is because of a bug surfaced when demoing the previous PR in that filtered branches would not show up as selected under the old logic.

Turns out the mapping of rows back to branches in the experiments webview was a little bit brittle. I have broken it on a few occasions and struggled to get it back working. The idea is to stabilise the logic by keeping it contained in a couple of places and slightly improve efficiency.

Demo (bug from previous PR)

Screen.Recording.2023-07-27.at.5.29.18.pm.mov

@mattseddon mattseddon self-assigned this Jul 27, 2023
@mattseddon mattseddon changed the base branch from main to filter-commits July 27, 2023 05:57
export const collectBranchWithRows = (
rows: Row<Experiment>[]
): [string | typeof WORKSPACE_BRANCH, Row<Experiment>[]][] => {
const branchesWithRows: [
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[F] Usually I would have just used an object here but you can't key an object using undefined | null so I opted for this slightly wacky collection pattern.

@@ -52,11 +49,9 @@ export const TableContent: React.FC<TableContentProps> = ({

return (
<>
{branches.map(branch => {
const branchRows = rows.filter(row => row.original.branch === branch)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[F] probably just because the focus is on efficiency this week but I decided that we should get this collection done in a single loop.

@mattseddon mattseddon force-pushed the refactor-branch-data branch 2 times, most recently from 8edcf15 to 0b5b22a Compare July 27, 2023 07:20
@mattseddon mattseddon marked this pull request as ready for review July 27, 2023 07:33
Base automatically changed from filter-commits to main July 27, 2023 19:29
@mattseddon mattseddon force-pushed the refactor-branch-data branch from 0b5b22a to 4d4e189 Compare July 27, 2023 19:31
@mattseddon mattseddon enabled auto-merge (squash) July 27, 2023 19:33
@mattseddon mattseddon force-pushed the refactor-branch-data branch from 4d4e189 to 571d924 Compare July 27, 2023 19:55
@codeclimate
Copy link

codeclimate bot commented Jul 27, 2023

Code Climate has analyzed commit 571d924 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 92.3% (85% is the threshold).

This pull request will bring the total coverage in the repository to 95.2%.

View more on Code Climate.

@mattseddon mattseddon merged commit c0f3902 into main Jul 27, 2023
@mattseddon mattseddon deleted the refactor-branch-data branch July 27, 2023 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants