Skip to content

Commit

Permalink
TW-1364 Change logic for the case extension version is not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
keshan3262 committed Apr 10, 2024
1 parent 1a80cd4 commit 2c96fa0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 31 deletions.
8 changes: 1 addition & 7 deletions src/advertising/external-ads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,7 @@ const compareVersions = (a: string, b: string) => {
return aPatch - bPatch;
};

export const filterByVersion = <T extends ExtVersionConstraints>(rules: T[], version?: string) => {
if (!isDefined(version)) {
return rules.filter(
({ firstExtVersion, lastExtVersion }) => !isDefined(firstExtVersion) && !isDefined(lastExtVersion)
);
}

export const filterByVersion = <T extends ExtVersionConstraints>(rules: T[], version = '1.20.1') => {
return rules.filter(({ firstExtVersion, lastExtVersion }) => {
if (isDefined(firstExtVersion) && compareVersions(firstExtVersion, version) > 0) {
return false;
Expand Down
30 changes: 12 additions & 18 deletions src/routers/slise-ad-rules/ad-places.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,8 @@ export const adPlacesRulesRouter = Router();
* name: extVersion
* schema:
* type: string
* description: >
* The extension version for which the rules should be returned. If not specified, the rules that are
* applicable for all extension versions will be returned.
* default: '1.20.1'
* description: The extension version for which the rules should be returned
* responses:
* '200':
* description: Rules list
Expand All @@ -369,9 +368,8 @@ export const adPlacesRulesRouter = Router();
* name: extVersion
* schema:
* type: string
* description: >
* The extension version for which the rules should be returned. If not specified, the rules that are
* applicable for all extension versions will be returned.
* default: '1.20.1'
* description: The extension version for which the rules should be returned
* responses:
* '200':
* description: Domain - rules list dictionary
Expand Down Expand Up @@ -496,9 +494,8 @@ addObjectStorageMethodsToRouter(adPlacesRulesRouter, {
* name: extVersion
* schema:
* type: string
* description: >
* The extension version for which the rules should be returned. If not specified, the rules that are
* applicable for all extension versions will be returned.
* default: '1.20.1'
* description: The extension version for which the rules should be returned
* responses:
* '200':
* description: Rules list
Expand All @@ -520,9 +517,8 @@ addObjectStorageMethodsToRouter(adPlacesRulesRouter, {
* name: extVersion
* schema:
* type: string
* description: >
* The extension version for which the rules should be returned. If not specified, the rules that are
* applicable for all extension versions will be returned.
* default: '1.20.1'
* description: The extension version for which the rules should be returned
* responses:
* '200':
* description: Domain - rules list dictionary
Expand Down Expand Up @@ -647,9 +643,8 @@ addObjectStorageMethodsToRouter(adPlacesRulesRouter, {
* name: extVersion
* schema:
* type: string
* description: >
* The extension version for which the rules should be returned. If not specified, the rules that are
* applicable for all extension versions will be returned.
* default: '1.20.1'
* description: The extension version for which the rules should be returned
* responses:
* '200':
* description: Rules list
Expand All @@ -671,9 +666,8 @@ addObjectStorageMethodsToRouter(adPlacesRulesRouter, {
* name: extVersion
* schema:
* type: string
* description: >
* The extension version for which the rules should be returned. If not specified, the rules that are
* applicable for all extension versions will be returned.
* default: '1.20.1'
* description: The extension version for which the rules should be returned
* responses:
* '200':
* description: Domain - rules list dictionary
Expand Down
10 changes: 4 additions & 6 deletions src/routers/slise-ad-rules/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,8 @@ addObjectStorageMethodsToRouter(adProvidersRouter, {
* name: extVersion
* schema:
* type: string
* description: >
* The extension version for which the rules should be returned. If not specified, the rules that are
* applicable for all extension versions will be returned.
* default: '1.20.1'
* description: The extension version for which the rules should be returned
* responses:
* '200':
* description: List of CSS selectors
Expand All @@ -379,9 +378,8 @@ addObjectStorageMethodsToRouter(adProvidersRouter, {
* name: extVersion
* schema:
* type: string
* description: >
* The extension version for which the rules should be returned. If not specified, the rules that are
* applicable for all extension versions will be returned.
* default: '1.20.1'
* description: The extension version for which the rules should be returned
* responses:
* '200':
* description: Provider - selectors dictionary
Expand Down

0 comments on commit 2c96fa0

Please sign in to comment.