Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

368 Sort City Council District Find Many by Id #371

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,13 @@ paths:
type: array
items:
$ref: '#/components/schemas/CityCouncilDistrict'
order:
type: string
description: City council districts ids are sorted as if numbers in ascending order
example: 'id'
required:
- cityCouncilDistricts
- order
'400':
$ref: '#/components/responses/BadRequest'
'500':
Expand Down Expand Up @@ -1067,8 +1072,8 @@ components:
id:
type: string
description: One or two character code to represent city council districts.
pattern: '^([0-9]{1,2})$'
example: 25
pattern: '^([0-9]{1,2})$'
example: '25'
required:
- id
CityCouncilDistrictGeoJson:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class CityCouncilDistrictRepository {
columns: {
id: true,
},
orderBy: sql`${cityCouncilDistrict.id}::integer ASC`,
});
} catch {
throw new DataRetrievalException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ describe("City Council District service unit", () => {
expect(() =>
findCityCouncilDistrictsQueryResponseSchema.parse(cityCouncilDistricts),
).not.toThrow();

expect(cityCouncilDistricts.order).toBe("id");
});
});

Expand Down
1 change: 1 addition & 0 deletions src/city-council-district/city-council-district.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class CityCouncilDistrictService {

return {
cityCouncilDistricts,
order: "id",
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/gen/schemas/CityCouncilDistrict.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"id": {
"description": "One or two character code to represent city council districts.",
"type": "string",
"example": 25,
"example": "25",
"pattern": "^([0-9]{1,2})$"
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/gen/schemas/CityCouncilDistrictGeoJson.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"id": {
"description": "One or two character code to represent city council districts.",
"type": "string",
"example": 25,
"example": "25",
"pattern": "^([0-9]{1,2})$"
}
},
Expand Down
10 changes: 10 additions & 0 deletions src/gen/types/FindCityCouncilDistricts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export type FindCityCouncilDistricts200 = {
* @type array
*/
cityCouncilDistricts: CityCouncilDistrict[];
/**
* @description City council districts ids are sorted as if numbers in ascending order
* @type string
*/
order: string;
};
/**
* @description Invalid client request
Expand All @@ -26,6 +31,11 @@ export type FindCityCouncilDistrictsQueryResponse = {
* @type array
*/
cityCouncilDistricts: CityCouncilDistrict[];
/**
* @description City council districts ids are sorted as if numbers in ascending order
* @type string
*/
order: string;
};
export type FindCityCouncilDistrictsQuery = {
Response: FindCityCouncilDistrictsQueryResponse;
Expand Down
10 changes: 10 additions & 0 deletions src/gen/zod/findCityCouncilDistrictsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { errorSchema } from "./errorSchema";
*/
export const findCityCouncilDistricts200Schema = z.object({
cityCouncilDistricts: z.array(z.lazy(() => cityCouncilDistrictSchema)),
order: z.coerce
.string()
.describe(
"City council districts ids are sorted as if numbers in ascending order",
),
});
/**
* @description Invalid client request
Expand All @@ -21,4 +26,9 @@ export const findCityCouncilDistricts500Schema = z.lazy(() => errorSchema);
*/
export const findCityCouncilDistrictsQueryResponseSchema = z.object({
cityCouncilDistricts: z.array(z.lazy(() => cityCouncilDistrictSchema)),
order: z.coerce
.string()
.describe(
"City council districts ids are sorted as if numbers in ascending order",
),
});