-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related keyphrase status neutral/orange instead of happy/green when a…
…ll the results are good #4475
- Loading branch information
Showing
4 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
packages/yoastseo/spec/scoring/scoreAggregators/RelatedKeywordScoreAggregatorSpec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { RelatedKeywordScoreAggregator } from "../../../src/scoring/scoreAggregators"; | ||
import AssessmentResult from "../../../src/values/AssessmentResult"; | ||
|
||
describe( "RelatedKeywordScoreAggregator", () => { | ||
let aggregator; | ||
|
||
beforeEach( () => { | ||
aggregator = new RelatedKeywordScoreAggregator(); | ||
} ); | ||
|
||
describe( "aggregate", () => { | ||
it( "exclude assessments without score from aggregator", () => { | ||
const results = [ | ||
new AssessmentResult( { score: 5 } ), | ||
new AssessmentResult(), | ||
new AssessmentResult( { score: 4 } ), | ||
new AssessmentResult( { score: 8 } ), | ||
new AssessmentResult(), | ||
]; | ||
const score = aggregator.aggregate( results ); | ||
expect( score ).toBe( 63 ); | ||
} ); | ||
} ); | ||
} ); |
35 changes: 35 additions & 0 deletions
35
packages/yoastseo/src/scoring/scoreAggregators/RelatedKeywordScoreAggregator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import SEOScoreAggregator from "./SEOScoreAggregator"; | ||
|
||
/** | ||
* Aggregates SEO assessment results into a single score. | ||
* | ||
* @memberOf module:parsedPaper/assess | ||
*/ | ||
class RelatedKeywordScoreAggregator extends SEOScoreAggregator { | ||
/** | ||
* Returns the list of valid results. | ||
* Valid results are all results that have a score. | ||
* | ||
* @param {AssessmentResult[]} results The results to filter the valid results from. | ||
* | ||
* @returns {AssessmentResult[]} The list of valid results. | ||
*/ | ||
getValidResults( results ) { | ||
return results.filter( result => result.hasScore() ); | ||
} | ||
|
||
/** | ||
* Aggregates the given assessment results into a single score. | ||
* | ||
* @param {AssessmentResult[]} results The assessment results. | ||
* | ||
* @returns {number} The aggregated score. | ||
*/ | ||
aggregate( results ) { | ||
const validResults = this.getValidResults( results ); | ||
|
||
return super.aggregate( validResults ); | ||
} | ||
} | ||
|
||
export default RelatedKeywordScoreAggregator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as ReadabilityScoreAggregator } from "./ReadabilityScoreAggregator"; | ||
export { default as RelatedKeywordScoreAggregator } from "./RelatedKeywordScoreAggregator"; | ||
export { default as ScoreAggregator } from "./ScoreAggregator"; | ||
export { default as SEOScoreAggregator } from "./SEOScoreAggregator"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters