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 isBeta challenges displaying without title when they should be hidden #12989

Closed

Conversation

systimotic
Copy link
Member

Pre-Submission Checklist

  • Your pull request targets the staging branch of freeCodeCamp.
  • Branch starts with either fix/, feature/, or translate/ (e.g. fix/signin-issue)
  • You have only one commit (if not, squash them into one commit).
  • All new and existing tests pass the command npm test. Use git commit --amend to amend any fixes.

Type of Change

  • Small bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds new functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Add new translation (feature adding new translations)

Checklist:

Description

Woo! So this is probably the biggest change I have made to date. A lot of hours went into understanding what's going on here.

Challenges with isBeta: true would display in production, but without title.
This was because the challenges weren't being filtered from the blocks. The titles were taken from the searchNames, which were filtered, so no title showed up.

@BerkeleyTrue This is my first time making a change this "major", and my first time changing the tests. Your review would be much appreciated.

@BerkeleyTrue BerkeleyTrue added the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label Jan 30, 2017
Copy link
Member

@Bouncey Bouncey left a comment

Choose a reason for hiding this comment

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

Some great work here, just a few pointers for keeping it functional 😃

block: Object.keys(blocks)
.map(dashedName => {
const block = blocks[dashedName];
let challenges = block.challenges;

This comment was marked as off-topic.

This comment was marked as off-topic.

.filter(filter)
.map(challenge => challenge.dashedName);
}
block.challenges = challenges;

This comment was marked as off-topic.

This comment was marked as off-topic.

.map(dashedName => {
const block = blocks[dashedName];
let challenges = block.challenges;
if (Array.isArray(challenges)) {

This comment was marked as off-topic.

This comment was marked as off-topic.

@@ -657,7 +657,6 @@
],
"type": "bonfire",
"isRequired": true,
"isBeta": true,

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@raisedadead raisedadead added the status: blocked Is waiting on followup from either the Opening Poster of the issue or PR, or a maintainer. label Feb 15, 2017
@systimotic
Copy link
Member Author

@Bouncey Thank you so much for reviewing! I'm sorry for taking so long, I've been a bit absent in the past two weeks and I completely forgot about this. I just pushed the requested updates. How are things now?

@systimotic systimotic removed the status: blocked Is waiting on followup from either the Opening Poster of the issue or PR, or a maintainer. label Feb 19, 2017
@systimotic
Copy link
Member Author

@Bouncey @BerkeleyTrue Can you review?

@systimotic
Copy link
Member Author

@Bouncey @BerkeleyTrue A review would be great!

@@ -657,7 +657,6 @@
],
"type": "bonfire",
"isRequired": true,
"isBeta": true,

This comment was marked as off-topic.

@BerkeleyTrue
Copy link
Contributor

@systimotic Sorry about that. I had requested changes a while back but I had failed to submit them.

@camperbot
Copy link
Contributor

@systimotic updated the pull request.

@systimotic
Copy link
Member Author

@BerkeleyTrue No worries!
That does make a whole lot of sense. I'll open an issue about the isBeta for the splicing challenge.
I updated the PR. How is it now?

.forEach(block => {
const challenges = actual.block[block].challenges;
challenges.forEach(challenge => challengesFromBlocks.push(challenge));
});

This comment was marked as off-topic.

Object.keys(actual.block)
.forEach(block => {
challengesFromBlocksCount += actual.block[block].challenges.length;
});

This comment was marked as off-topic.

.forEach(block => {
challengesFromBlocksCount += actual.block[block].challenges.length;
});
console.log(challengesFromBlocksCount, actual.block);

This comment was marked as off-topic.

@dhcodes
Copy link
Contributor

dhcodes commented Aug 2, 2017

@systimotic This PR would also fix the new issue #15705. Do you plan to update this or do you want to start from scratch now that there have been a few updates to the base? I can take a stab at it as well, but looks like you're already a bit farther down the road to solving it.

@camperbot
Copy link
Contributor

@systimotic updated the pull request.

@@ -10,12 +10,30 @@ export function filterComingSoonBetaChallenge(
}

export function filterComingSoonBetaFromEntities(
{ challenge: challengeMap, ...rest },
{ challenge: challengeMap, block: blocks, ...rest },

This comment was marked as off-topic.

This comment was marked as off-topic.

@BerkeleyTrue
Copy link
Contributor

@systimotic Thanks for the PR. I think this will do for now (other than my nit pick above). The issue with this approach is now all the challenges are iterated through twice in addition to the blocks. We now have over 400 challenges and 60+ blocks, so this function went from iterating 400+ times to more like 900+ times. This is a very costly function now. Not your fault, but we will need to come up with a more integrated solution that does not involving iterating through all the challenges and instead filters out during nextChallenge and map rendering.

Other than the nitpick above code LGTM. If someone could run it and verify it's ready to merge.

@camperbot
Copy link
Contributor

@systimotic updated the pull request.

@systimotic
Copy link
Member Author

systimotic commented Aug 24, 2017

@BerkeleyTrue Yeah, it's not ideal. Should we stick with the workaround from #15741 instead?

Also, previously you mentioned some loops in the tests should be changed to reduce. Should I still do that?

@BerkeleyTrue
Copy link
Contributor

Merged!!! 0129116

Happy Coding!

@BerkeleyTrue BerkeleyTrue removed the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label Sep 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants