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

4475 fix related keyphrase status #21941

Open
wants to merge 11 commits into
base: trunk
Choose a base branch
from

Conversation

mykola
Copy link
Contributor

@mykola mykola commented Jan 2, 2025

Context

  • Fix the related keyphrase status from orange to green when all the assessment results are good.

Summary

This PR can be summarized in the following changelog entry:

  • [yoastseo] Fixes a bug where the related keyphrase score would still be orange even when all the assessment results were good.
  • [shopify-seo] Fixes a bug where the related keyphrase score would still be orange even when all the assessment results were good.

Relevant technical choices:

  • New RelatedKeywordScoreAggregator was added before the aggregate filter assessments without a score. A similar approach is used in ReadabilityScoreAggregator. Also score aggregator is introduced as a field for Accessor classes By default is SEOScoreAggregator and redefined for RelatedKeywordAssessor and ContentAssessor

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Create a post with content (this article can be used).
  • Click Add related keyphrase -> Keyphrase: insights
  • Make sure that scores are green for every assessment.
  • Make sure that the score of the Related keyphrase emote is happy/green (one in the header of Related keyphrase)
  • Run the test in WordPress and in Shopify

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • For solution separate a separate score aggregator was introduced that should impact only Related Keyword but please do a smoke test for Premium SEO analysis.

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes #4475

@coveralls
Copy link

coveralls commented Jan 2, 2025

Pull Request Test Coverage Report for Build bde29a854458a44f50df09b5ee9194caa3447402

Details

  • 11 of 11 (100.0%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.004%) to 54.488%

Totals Coverage Status
Change from base Build b0de0678bd136a274f1325cb65b549ab454c8b94: 0.004%
Covered Lines: 30089
Relevant Lines: 55617

💛 - Coveralls

@mykola mykola added changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog Shopify This PR impacts Shopify. changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog and removed changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog labels Jan 2, 2025
@mykola mykola marked this pull request as ready for review January 2, 2025 11:18
@Jordi-PV Jordi-PV modified the milestones: 24.3, 24.4 Jan 8, 2025
mykola added 3 commits January 9, 2025 15:05
…ll the results are good

#4475
Remove related keyword score aggregator and move filter into base SEOScoreAggregator
@mhkuu mhkuu removed this from the 24.4 milestone Jan 16, 2025
Copy link
Contributor

@mhkuu mhkuu left a comment

Choose a reason for hiding this comment

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

Nice work, but please do take the opportunity to refactor and reduce this code further now that we are touching it 👍

... otherwise we would need to do it anyway as part of resolving technical debt later on 😅

In terms of solving the bug, this PR solves the case for related keyphrase analysis, but specifically for the SEO analysis in collections in Shopify, we decided we would use the same aggregation strategy. So, we can add a custom score aggregator for those assessors (packages/yoastseo/src/scoring/assessors/collectionPages/seoAssessor.js and packages/yoastseo/src/scoring/assessors/collectionPages/cornerstone/seoAssessor.js) as well 👍

@@ -1157,16 +1149,15 @@ export default class AnalysisWebWorker {
* @param {Paper} paper The paper to analyze.
* @param {module:parsedPaper/structure.Node} tree The tree to analyze.
*
* @param {Object} analysisCombination Which assessors and score aggregator to use.
* @param {Object} analysisCombination Which assessors to use.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great if we take this opportunity to remove the TreeAssessor references here. So, instead of an analysisCombination, just have assessor as the argument of this function.

Also, the fields that are created in setupTreeAnalysis (e.g., _contentTreeAssessor, _seoTreeAssessor, _relatedKeywordTreeAssessor) can be removed, along with all commented code.

@@ -1243,11 +1234,10 @@ export default class AnalysisWebWorker {
synonyms: this._relatedKeywords[ key ].synonyms,
} );

// Which combination of (tree) assessors and score aggregator to use.
// Which combination of (tree) assessors to use.
Copy link
Contributor

Choose a reason for hiding this comment

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

... and we can also call the this.assess function with just a Paper and an Assessor.

// Set the locale (we are more lenient for languages that have full analysis support).
analysisCombination.scoreAggregator.setLocale( this._configuration.locale );
analysisCombination.oldAssessor.getScoreAggregator().setLocale( this._configuration.locale );
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not nice that this function is only available to the ReadabilityScoreAggregator. I would consider moving it to the abstract base class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog Shopify This PR impacts Shopify.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants