Skip to content

Commit

Permalink
HARMONY-1889: Replace averagingType with average to be consistent wit…
Browse files Browse the repository at this point in the history
…h our API parameters.
  • Loading branch information
chris-durbin committed Sep 25, 2024
1 parent 3446b9d commit cf4aed4
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions services/harmony/app/markdown/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ As such it accepts parameters in the URL path as well as query parameters.
| ignoreErrors | if "true", continue processing a request to completion even if some items fail. If "false" immediately fail the request. Defaults to true |
| destinationUrl | destination url specified by the client; currently only s3 link urls are supported (e.g. s3://my-bucket-name/mypath) and will result in the job being run asynchronously |
| variable | the variable(s) to be used for variable subsetting. Multiple variables can be specified as a comma-separated list. This parameter is only used if the url `variable` path element is "parameter_vars" |
| averagingType | requests the data to be averaged over either time or area |
| average | requests the data to be averaged over either time or area |
---
**Table {{tableCounter}}** - Harmony OGC Coverages API query parameters

Expand Down Expand Up @@ -132,7 +132,7 @@ Currently only the `/position`, `/cube`, `/trajectory` and `/area` routes are su
| subset | get a subset of the coverage by slicing or trimming along one axis. Harmony supports arbitrary dimension names for subsetting on numeric ranges for that dimension. |
| height | number of rows to return in the output coverage |
| width | number of columns to return in the output coverage |
| averagingType | requests the data to be averaged over either time or area |
| average | requests the data to be averaged over either time or area |
---
**Table {{tableCounter}}** - Harmony extended parameters for all OGC EDR API routes

Expand Down
2 changes: 1 addition & 1 deletion services/harmony/app/models/data-operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export default class DataOperation {

ignoreErrors?: boolean;

averagingType: string;
average: string;

destinationUrl: string;

Expand Down
4 changes: 2 additions & 2 deletions services/harmony/app/models/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ function supportsDimensionSubsetting(configs: ServiceConfig<unknown>[]): Service
* @returns true if the provided operation requires time averaging and false otherwise
*/
function requiresTimeAveraging(operation: DataOperation): boolean {
return operation.averagingType === 'time';
return operation.average === 'time';
}

/**
Expand All @@ -472,7 +472,7 @@ function supportsTimeAveraging(configs: ServiceConfig<unknown>[]): ServiceConfig
* @returns true if the provided operation requires area averaging and false otherwise
*/
function requiresAreaAveraging(operation: DataOperation): boolean {
return operation.averagingType === 'area';
return operation.average === 'area';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ paths:
- $ref: "#/components/parameters/grid"
- $ref: "#/components/parameters/extend"
- $ref: "#/components/parameters/variable"
- $ref: "#/components/parameters/averagingType"
- $ref: "#/components/parameters/average"
responses:
"200":
description: A coverage's range set.
Expand Down Expand Up @@ -385,7 +385,7 @@ paths:
- $ref: "#/components/parameters/grid"
- $ref: "#/components/parameters/extend"
- $ref: "#/components/parameters/variable"
- $ref: "#/components/parameters/averagingType"
- $ref: "#/components/parameters/average"
requestBody:
content:
multipart/form-data:
Expand Down Expand Up @@ -986,8 +986,8 @@ components:
items:
type: string
minLength: 1
averagingType:
name: averagingType
average:
name: average
in: query
description: |
requests the data to be averaged over time or area
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ paths:
- $ref: "#/components/parameters/granuleName"
- $ref: "#/components/parameters/grid"
- $ref: "#/components/parameters/extend"
- $ref: "#/components/parameters/averagingType"
- $ref: "#/components/parameters/average"
responses:
"200":
description: A collection's EDR.
Expand Down Expand Up @@ -259,7 +259,7 @@ paths:
type: string
extend:
type: string
averagingType:
average:
type: string
responses:
"200":
Expand Down Expand Up @@ -307,7 +307,7 @@ paths:
- $ref: "#/components/parameters/granuleName"
- $ref: "#/components/parameters/grid"
- $ref: "#/components/parameters/extend"
- $ref: "#/components/parameters/averagingType"
- $ref: "#/components/parameters/average"
responses:
"200":
description: A collection's EDR.
Expand Down Expand Up @@ -400,7 +400,7 @@ paths:
type: string
extend:
type: string
averagingType:
average:
type: string
responses:
"200":
Expand Down Expand Up @@ -448,7 +448,7 @@ paths:
- $ref: "#/components/parameters/granuleName"
- $ref: "#/components/parameters/grid"
- $ref: "#/components/parameters/extend"
- $ref: "#/components/parameters/averagingType"
- $ref: "#/components/parameters/average"
responses:
"200":
description: A collection's EDR.
Expand Down Expand Up @@ -539,7 +539,7 @@ paths:
type: string
extend:
type: string
averagingType:
average:
type: string
responses:
"200":
Expand Down Expand Up @@ -585,7 +585,7 @@ paths:
- $ref: "#/components/parameters/granuleName"
- $ref: "#/components/parameters/grid"
- $ref: "#/components/parameters/extend"
- $ref: "#/components/parameters/averagingType"
- $ref: "#/components/parameters/average"
responses:
"200":
description: A collection's EDR.
Expand Down Expand Up @@ -671,7 +671,7 @@ paths:
type: string
extend:
type: string
averagingType:
average:
type: string
responses:
"200":
Expand Down Expand Up @@ -717,7 +717,7 @@ paths:
- $ref: "#/components/parameters/granuleName"
- $ref: "#/components/parameters/grid"
- $ref: "#/components/parameters/extend"
- $ref: "#/components/parameters/averagingType"
- $ref: "#/components/parameters/average"
responses:
"200":
description: A collection's EDR.
Expand Down Expand Up @@ -804,7 +804,7 @@ paths:
type: string
extend:
type: string
averagingType:
average:
type: string
responses:
"200":
Expand Down Expand Up @@ -856,7 +856,7 @@ paths:
- $ref: "#/components/parameters/granuleName"
- $ref: "#/components/parameters/grid"
- $ref: "#/components/parameters/extend"
- $ref: "#/components/parameters/averagingType"
- $ref: "#/components/parameters/average"
responses:
"200":
description: A collection's EDR.
Expand Down Expand Up @@ -959,7 +959,7 @@ paths:
type: string
extend:
type: string
averagingType:
average:
type: string
responses:
"200":
Expand Down Expand Up @@ -1662,8 +1662,8 @@ components:
required: false
schema:
type: string
averagingType:
name: averagingType
average:
name: average
in: query
description: |
requests the data to be averaged over time or area
Expand Down
8 changes: 4 additions & 4 deletions services/harmony/app/util/parameter-parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ export function handleWidth(
export function handleAveragingType(
operation: DataOperation,
query: Record<string, string>): void {
if (query.averagingtype) {
const value = query.averagingtype.toLowerCase();
if (query.average) {
const value = query.average.toLowerCase();
if (value !== 'time' && value !== 'area') {
throw new RequestValidationError('query parameter "averagingType" must be either "time" or "area"');
throw new RequestValidationError('query parameter "average" must be either "time" or "area"');
}
operation.averagingType = value;
operation.average = value;
}
}
4 changes: 2 additions & 2 deletions services/harmony/test/models/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe('services.chooseServiceConfig and services.buildService', function () {

describe('and the request needs area averaging', function () {
beforeEach(function () {
this.operation.averagingType = 'area';
this.operation.average = 'area';
});

it('chooses the service that supports area averaging', function () {
Expand All @@ -212,7 +212,7 @@ describe('services.chooseServiceConfig and services.buildService', function () {

describe('and the request needs time averaging', function () {
beforeEach(function () {
this.operation.averagingType = 'time';
this.operation.average = 'time';
});

it('chooses the service that supports time averaging', function () {
Expand Down
24 changes: 12 additions & 12 deletions services/harmony/test/parameters/averaging_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { partialApply } from '../helpers/util';
const collection = 'C1233800302-EEDTEST';
const edrVersion = '1.1.0';

// We want to test the averagingType parameter on each of the following APIs, so we'll
// We want to test the average parameter on each of the following APIs, so we'll
// run the same tests against each in a loop
const endpointFunctions = [{
label: 'OGC Coverages',
Expand All @@ -39,12 +39,12 @@ const endpointFunctions = [{
}];

for (const { label, endpointFn, extraArgs } of endpointFunctions) {
describe(`averagingType for ${label} API`, function () {
describe(`average for ${label} API`, function () {
hookServersStartStop();

describe('when making a request with averagingType time', function () {
describe('when making a request with average time', function () {
const averagingTimeQuery = {
averagingType: 'time',
average: 'time',
};

describe('for a collection that can support it', function () {
Expand All @@ -57,7 +57,7 @@ for (const { label, endpointFn, extraArgs } of endpointFunctions) {
});

xit('specifies to perform time averaging in the operation', async function () {
expect(this.service.operation.averagingType).to.equal('time');
expect(this.service.operation.average).to.equal('time');
});
});

Expand All @@ -77,9 +77,9 @@ for (const { label, endpointFn, extraArgs } of endpointFunctions) {
});
});

describe('when making a request with averagingType area', function () {
describe('when making a request with average area', function () {
const averagingAreaQuery = {
averagingType: 'area',
average: 'area',
};

describe('for a collection that can support it', function () {
Expand All @@ -92,7 +92,7 @@ for (const { label, endpointFn, extraArgs } of endpointFunctions) {
});

xit('specifies to perform area averaging in the operation', async function () {
expect(this.service.operation.averagingType).to.equal('area');
expect(this.service.operation.average).to.equal('area');
});
});

Expand All @@ -112,20 +112,20 @@ for (const { label, endpointFn, extraArgs } of endpointFunctions) {
});
});

describe('when making a request with an invalid averagingType', function () {
describe('when making a request with an invalid average', function () {
const badAveragingQuery = {
averagingType: 'no not that',
average: 'no not that',
};
endpointFn({ query: { ...badAveragingQuery, ...extraArgs } });

it('returns a 400 status code for the request', async function () {
expect(this.res.status).to.equal(400);
});

it('returns a message indicating that the averagingType value is invalid', async function () {
it('returns a message indicating that the average value is invalid', async function () {
const errorMessage = {
'code': 'harmony.RequestValidationError',
'description': 'Error: query parameter "averagingType" must be either "time" or "area"',
'description': 'Error: query parameter "average" must be either "time" or "area"',
};
expect(this.res.body).to.eql(errorMessage);
});
Expand Down

0 comments on commit cf4aed4

Please sign in to comment.