Skip to content

Commit

Permalink
add history attribute to the get reports external api
Browse files Browse the repository at this point in the history
  • Loading branch information
goemen committed May 9, 2024
1 parent 6c7c92e commit d34c35f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 4 additions & 0 deletions backend-external/src/v1/routes/pay-transparency-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ const router = express.Router();
* type: array
* items:
* $ref: "#/components/schemas/Report"
* history:
* type: array
* items:
* $ref: "#/components/schemas/Report"
*
*/

Expand Down
1 change: 1 addition & 0 deletions backend/src/v1/routes/external-consumer-routes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ describe('external-consumer-routes', () => {
expect(body).toEqual({
page: 0,
pageSize: 1000,
history: [],
records: [
{
calculated_data: [
Expand Down
2 changes: 1 addition & 1 deletion backend/src/v1/services/external-consumer-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 9 additions & 9 deletions backend/src/v1/services/external-consumer-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
),
};
}),
],
};
},
Expand Down

0 comments on commit d34c35f

Please sign in to comment.