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

Fix #2361: Extract unique github urls from each post #2363

Merged

Conversation

Andrewnt219
Copy link
Contributor

@Andrewnt219 Andrewnt219 commented Oct 16, 2021

Issue This PR Addresses

Fix #2361

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

Add a function to extract all the unique Github links from each post.

Test plan

const htmlString = `
<-- Duplicate links -->
<a href="https://github.com/user/repo/issues/1">Issue 1</a>
<a href="https://github.com/user/repo/issues/1">Issue 1</a>

<a href="https://github.com/user/repo">Repo 1</a>
<a href="https://github.com/user/repo/pull/2">Pull Request 1</a>
`;

extractGitHubUrlsFromPost(htmlString); // ["https://github.com/user/repo/issues/1", "https://github.com/user/repo", "https://github.com/user/repo/pull/2" ]
`

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

@Andrewnt219 Andrewnt219 marked this pull request as ready for review October 16, 2021 04:29
@Andrewnt219 Andrewnt219 changed the title Fix #2361: Extract unique github url from each post Fix #2361: Extract unique github urls from each post Oct 16, 2021
Copy link
Member

@manekenpix manekenpix left a comment

Choose a reason for hiding this comment

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

Nice!
I left a few comments, but I think it's almost there 👍

src/web/src/components/Posts/Post.tsx Outdated Show resolved Hide resolved
src/web/src/components/Posts/Post.tsx Outdated Show resolved Hide resolved
src/web/src/components/Posts/Post.tsx Outdated Show resolved Hide resolved
Copy link
Member

@manekenpix manekenpix left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

This looks good. A few questions:

  1. what about splitting these up into repos, issues, prs?
  2. should we move this into a hook, const { repos, issues, prs } = useGitHubUrls(post.html)? That way we can manage any changes to the post and post.html and (re)create these.
  3. this seems pretty testable. Should we add some?

All of this could happen in follow-up PRs by you or other people, or we could do it here. Let me know how you want to proceed.

@Andrewnt219
Copy link
Contributor Author

Andrewnt219 commented Oct 17, 2021

@humphd

  1. When I talked to Francesco, he had already been working on the filter function.
  2. The filterGithubIssues can call this extractGitHubUrlsFromPost internally. These two functions don't need to hook into React lifecycle, so I don't think making them a hook is necessary.
  3. I did look through the test folder for a suitable test setup, but I only found backend test code. Did I look at the wrong place?

As they are all relevant to this function, I can add more commits to this PR.

@humphd
Copy link
Contributor

humphd commented Oct 17, 2021

  • When I talked to Francesco, he had already been working on the filter function.

Alright, that's fine.

  • The filterGithubIssues can call this extractGitHubUrlsFromPost internally. These two functions don't need to hook into React lifecycle, so I don't think making them a hook is necessary.

OK

  • I did look through the test folder for a suitable test setup, but I only found backend test code. Did I look at the wrong place?

Our front-end tests are very basic at the moment. We only have a few snapshot tests for a couple of components. Let's try to get more in when @menghif's work gets added.

@humphd humphd merged commit 1fd819a into Seneca-CDOT:master Oct 17, 2021
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.

Extract GitHub URLs from posts before rendering
3 participants