diff --git a/backend-external/src/v1/routes/pay-transparency-routes.ts b/backend-external/src/v1/routes/pay-transparency-routes.ts index 25eb9d7b..59c12863 100644 --- a/backend-external/src/v1/routes/pay-transparency-routes.ts +++ b/backend-external/src/v1/routes/pay-transparency-routes.ts @@ -87,6 +87,10 @@ const router = express.Router(); * type: array * items: * $ref: "#/components/schemas/Report" + * history: + * type: array + * items: + * $ref: "#/components/schemas/Report" * */ diff --git a/backend/src/v1/routes/external-consumer-routes.spec.ts b/backend/src/v1/routes/external-consumer-routes.spec.ts index 873d3d92..6e91033a 100644 --- a/backend/src/v1/routes/external-consumer-routes.spec.ts +++ b/backend/src/v1/routes/external-consumer-routes.spec.ts @@ -79,6 +79,7 @@ describe('external-consumer-routes', () => { expect(body).toEqual({ page: 0, pageSize: 1000, + history: [], records: [ { calculated_data: [ diff --git a/backend/src/v1/services/external-consumer-service.spec.ts b/backend/src/v1/services/external-consumer-service.spec.ts index 47a1b69b..d8fb00a8 100644 --- a/backend/src/v1/services/external-consumer-service.spec.ts +++ b/backend/src/v1/services/external-consumer-service.spec.ts @@ -144,7 +144,7 @@ describe('external-consumer-service', () => { user_comment: testData.user_comment, }); - expect(results.records[1]).toStrictEqual({ + expect(results.history[0]).toStrictEqual({ calculated_data: [ { is_suppressed: diff --git a/backend/src/v1/services/external-consumer-service.ts b/backend/src/v1/services/external-consumer-service.ts index b068712d..6ca27662 100644 --- a/backend/src/v1/services/external-consumer-service.ts +++ b/backend/src/v1/services/external-consumer-service.ts @@ -165,6 +165,15 @@ const externalConsumerService = { return { page: offset, pageSize: limit, + history: flatten(results.map((r) => r.report_history)).map((report) => { + return { + ...denormalizeReport( + report, + (r) => r.naics_code_report_history_naics_codeTonaics_code, + (r) => r.calculated_data_history, + ), + }; + }), records: [ ...results.map((report) => { return { @@ -176,15 +185,6 @@ const externalConsumerService = { ), }; }), - ...flatten(results.map((r) => r.report_history)).map((report) => { - return { - ...denormalizeReport( - report, - (r) => r.naics_code_report_history_naics_codeTonaics_code, - (r) => r.calculated_data_history, - ), - }; - }), ], }; },