@studyportals/fawkes 8.0.1-4 → 8.0.1-6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { PortalType } from '@studyportals/domain-client';
2
2
  import { SortingOptions } from '../../enums/SortingOptions';
3
3
  import { OrganisationsSeoIndexabilityPolicy } from './OrganisationsSeoIndexabilityPolicy';
4
- import { AtLeastTwoRankedResultsRule } from '../rules/AtLeastTwoRankedResultsRule';
4
+ import { AtLeastSevenRankedResultsRule } from '../rules/AtLeastSevenRankedResultsRule';
5
5
  export class RankedOrganisationsSeoIndexabilityPolicy extends OrganisationsSeoIndexabilityPolicy {
6
6
  indexablePortalTypes = [PortalType.MASTER];
7
7
  sortingOption = SortingOptions.UNIVERSITY_META_RANKING;
@@ -9,10 +9,10 @@ export class RankedOrganisationsSeoIndexabilityPolicy extends OrganisationsSeoIn
9
9
  let rankedResultsCountRule;
10
10
  if (super.isSitemapUrlGeneratorDependencies()) {
11
11
  const dependencies = this.dependencies;
12
- rankedResultsCountRule = new AtLeastTwoRankedResultsRule(dependencies.rankingApiClient);
12
+ rankedResultsCountRule = new AtLeastSevenRankedResultsRule(dependencies.rankingApiClient);
13
13
  }
14
14
  else {
15
- rankedResultsCountRule = new AtLeastTwoRankedResultsRule();
15
+ rankedResultsCountRule = new AtLeastSevenRankedResultsRule();
16
16
  }
17
17
  this.addRule(rankedResultsCountRule);
18
18
  }
@@ -0,0 +1,13 @@
1
+ import { IRule } from '../../common/IRule';
2
+ import { IOrganisationSearchDependencies } from '../types/IOrganisationSearchDependencies';
3
+ import { FilterKeyValuesMap } from '../../common/FilterKeyValuesMap';
4
+ import { IRankingApiClient } from '../../sitemap-generator/IRankingApiClient';
5
+ export declare class AtLeastSevenRankedResultsRule implements IRule {
6
+ private readonly minimumRankedResultsCount;
7
+ private readonly rankingApiClient?;
8
+ constructor(rankingApiClient?: IRankingApiClient);
9
+ forSearch(dependencies: IOrganisationSearchDependencies): Promise<boolean>;
10
+ forSitemapGenerator(filterKeyValues: FilterKeyValuesMap): Promise<boolean>;
11
+ getName(): string;
12
+ getDescription(): string;
13
+ }
@@ -0,0 +1,26 @@
1
+ import { DependencyMissingError } from '../../errors/DependencyMissingError';
2
+ export class AtLeastSevenRankedResultsRule {
3
+ minimumRankedResultsCount = 7;
4
+ rankingApiClient;
5
+ constructor(rankingApiClient) {
6
+ this.rankingApiClient = rankingApiClient;
7
+ }
8
+ forSearch(dependencies) {
9
+ const { applicationState } = dependencies;
10
+ const rankedResultsCount = applicationState.getRankedResultsCount();
11
+ return Promise.resolve(rankedResultsCount >= this.minimumRankedResultsCount);
12
+ }
13
+ async forSitemapGenerator(filterKeyValues) {
14
+ if (!this.rankingApiClient) {
15
+ throw new DependencyMissingError('RankingApiClient');
16
+ }
17
+ const rankedResultsCount = await this.rankingApiClient.getRankedOrganisationCount(filterKeyValues);
18
+ return rankedResultsCount >= this.minimumRankedResultsCount;
19
+ }
20
+ getName() {
21
+ return 'AtLeastTwoRankedResultsRule';
22
+ }
23
+ getDescription() {
24
+ return `At least ${this.minimumRankedResultsCount} ranked results are available`;
25
+ }
26
+ }
@@ -9,7 +9,7 @@ export declare class AtLeastSevenResultsRule implements IRule {
9
9
  constructor(searchApiClient?: ISearchApiClient);
10
10
  forSearch(dependencies: ISearchDependencies): Promise<boolean>;
11
11
  forSitemapGeneratorWithPageNumber(filterKeyValues: FilterKeyValuesMap, pageNumber: number): Promise<boolean>;
12
- forSitemapGenerator(): Promise<boolean>;
12
+ forSitemapGenerator(filterKeyValues: FilterKeyValuesMap): Promise<boolean>;
13
13
  getName(): string;
14
14
  getDescription(): string;
15
15
  }
@@ -18,13 +18,17 @@ export class AtLeastSevenResultsRule {
18
18
  const count = await this.searchApiClient.getCount(filterKeyValues);
19
19
  return count >= (pageNumber - 1) * this.maximumPageSize + this.minimumResultsCount;
20
20
  }
21
- forSitemapGenerator() {
22
- throw new Error('Method not implemented.');
21
+ async forSitemapGenerator(filterKeyValues) {
22
+ if (!this.searchApiClient) {
23
+ throw new DependencyMissingError('SearchApiClient');
24
+ }
25
+ const resultsCount = await this.searchApiClient?.getCount(filterKeyValues);
26
+ return resultsCount >= this.minimumResultsCount;
23
27
  }
24
28
  getName() {
25
29
  return 'AtLeastSevenResultsRule';
26
30
  }
27
31
  getDescription() {
28
- return 'Is indexable if there are at least 2 results.';
32
+ return 'Is indexable if there are at least 6 results.';
29
33
  }
30
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studyportals/fawkes",
3
- "version": "8.0.1-4",
3
+ "version": "8.0.1-6",
4
4
  "description": "A package to centralize SEO related logic for SBLP and Sitemap Generator.",
5
5
  "files": [
6
6
  "./dist"
@@ -11,7 +11,7 @@
11
11
  "compile": "npx tsc && tsc-alias && rm -r ./dist/tests",
12
12
  "build": "npm run clean && npm run compile",
13
13
  "clean": "rimraf \"!(node_modules)/**/dist\"",
14
- "prepare-deployment": "npm run build",
14
+ "prepare-deployment": "npm run test && npm run build",
15
15
  "publish-major": "npm run prepare-deployment && npm version major && npm publish",
16
16
  "publish-beta": "npm run prepare-deployment && npm version prerelease && npm publish --tag beta --access=public",
17
17
  "publish-patch": "npm run prepare-deployment && npm version patch && npm publish",
@@ -92,7 +92,7 @@
92
92
  "dependencies": {
93
93
  "@studyportals/domain-client": "^6.3.0",
94
94
  "@studyportals/ranking-api-interface": "^1.3.12",
95
- "@studyportals/search-filters": "^6.0.0",
95
+ "@studyportals/search-filters": "^6.1.0",
96
96
  "@studyportals/static-domain-data": "^6.1.0"
97
97
  },
98
98
  "optionalDependencies": {