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

fix(v1.6.0): return first child location from query #7867

Merged
merged 11 commits into from
Oct 30, 2024
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@

- Remove informant notification configuration from the UI and read notification configuration settings from `record-notification` endpoint in countryconfig
- Remove `DEL /elasticIndex` endpoint due reindexing changes.
- Gateways searchEvents `operationHistories` only returns `operationType` & `operatedOn` due to the other fields being unused in OpenCRVS
- Core used to provide review/preview section by default which are now removed and need to be provided from countryconfig. The signature field definitions (e.g. informant signature, bride signature etc.) were hard coded in core which also have now been removed. The signatures can now be added through the review/preview sections defined in countryconfig just like any other field. You can use the following section definition as the default which is without any additional fields. We highly recommend checking out our reference country repository which has the signature fields in it's review/preview sections

- **Gateways searchEvents API updated** `operationHistories` only returns `operationType` & `operatedOn` due to the other fields being unused in OpenCRVS
- **Config changes to review/preview and signatures** Core used to provide review/preview section by default which are now removed and need to be provided from countryconfig. The signature field definitions (e.g. informant signature, bride signature etc.) were hard coded in core which also have now been removed. The signatures can now be added through the review/preview sections defined in countryconfig just like any other field. You can use the following section definition as the default which is without any additional fields. We highly recommend checking out our reference country repository which has the signature fields in its review/preview sections
- `hasChildLocation` query has been removed from gateway. We have created the query `isLeafLevelLocation` instead which is more descriptive on its intended use.
```
{
id: 'preview',
Expand Down
14 changes: 9 additions & 5 deletions packages/client/graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13997,11 +13997,11 @@
"deprecationReason": null
},
{
"name": "hasChildLocation",
"name": "isLeafLevelLocation",
"description": null,
"args": [
{
"name": "parentId",
"name": "locationId",
"description": null,
"type": {
"kind": "NON_NULL",
Expand All @@ -14018,9 +14018,13 @@
}
],
"type": {
"kind": "OBJECT",
"name": "Location",
"ofType": null
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
Expand Down
1 change: 0 additions & 1 deletion packages/client/src/tests/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,6 @@ type Query {
): RegistrationCountResult
fetchMarriageRegistration(id: ID!): MarriageRegistration
fetchRecordDetailsForVerification(id: String!): RecordDetails
hasChildLocation(parentId: String!): Location
getUser(userId: String): User
getUserByMobile(mobile: String): User
getUserByEmail(email: String): User
Expand Down
2 changes: 0 additions & 2 deletions packages/client/src/utils/gateway-deprecated-do-not-use.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export interface GQLQuery {
fetchRecordDetailsForVerification?: GQLRecordDetails
locationsByParent?: Array<GQLLocation | null>
locationById?: GQLLocation
hasChildLocation?: GQLLocation
getUser?: GQLUser
getUserByMobile?: GQLUser
getUserByEmail?: GQLUser
Expand Down Expand Up @@ -2053,7 +2052,6 @@ export interface GQLQueryTypeResolver<TParent = any> {
fetchRecordDetailsForVerification?: QueryToFetchRecordDetailsForVerificationResolver<TParent>
locationsByParent?: QueryToLocationsByParentResolver<TParent>
locationById?: QueryToLocationByIdResolver<TParent>
hasChildLocation?: QueryToHasChildLocationResolver<TParent>
getUser?: QueryToGetUserResolver<TParent>
getUserByMobile?: QueryToGetUserByMobileResolver<TParent>
getUserByEmail?: QueryToGetUserByEmailResolver<TParent>
Expand Down
163 changes: 74 additions & 89 deletions packages/client/src/utils/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ export type Query = {
getUserByEmail?: Maybe<User>
getUserByMobile?: Maybe<User>
getVSExports?: Maybe<TotalVsExport>
hasChildLocation?: Maybe<Location>
isLeafLevelLocation: Scalars['Boolean']
listBirthRegistrations?: Maybe<BirthRegResultSet>
queryPersonByIdentifier?: Maybe<Person>
queryPersonByNidIdentifier?: Maybe<Person>
Expand Down Expand Up @@ -1567,8 +1567,8 @@ export type QueryGetUserByMobileArgs = {
mobile?: InputMaybe<Scalars['String']>
}

export type QueryHasChildLocationArgs = {
parentId: Scalars['String']
export type QueryIsLeafLevelLocationArgs = {
locationId: Scalars['String']
}

export type QueryListBirthRegistrationsArgs = {
Expand Down Expand Up @@ -7306,22 +7306,13 @@ export type GetLocationStatisticsQuery = {
} | null
}

export type HasChildLocationQueryVariables = Exact<{
parentId: Scalars['String']
export type IsLeafLevelLocationQueryVariables = Exact<{
locationId: Scalars['String']
}>

export type HasChildLocationQuery = {
export type IsLeafLevelLocationQuery = {
__typename?: 'Query'
hasChildLocation?: {
__typename?: 'Location'
id: string
type?: string | null
identifier?: Array<{
__typename?: 'Identifier'
system?: string | null
value?: string | null
}> | null
} | null
isLeafLevelLocation: boolean
}

export type FetchMonthWiseEventMetricsQueryVariables = Exact<{
Expand Down Expand Up @@ -7449,82 +7440,76 @@ export type GetRegistrationsListByFilterQueryVariables = Exact<{
size: Scalars['Int']
}>

export type RegistrationsListByLocationFilter = {
__typename: 'TotalMetricsByLocation'
total?: number | null
results: Array<{
__typename?: 'EventMetricsByLocation'
total: number
late: number
delayed: number
home: number
healthFacility: number
location: { __typename?: 'Location'; name?: string | null }
}>
}

export type RegistrationsListByRegistrarFilter = {
__typename: 'TotalMetricsByRegistrar'
total?: number | null
results: Array<{
__typename?: 'EventMetricsByRegistrar'
total: number
late: number
delayed: number
registrarPractitioner?: {
__typename?: 'User'
id: string
systemRole: SystemRoleType
role: {
__typename?: 'Role'
_id: string
labels: Array<{
__typename?: 'RoleLabel'
lang: string
label: string
}>
}
primaryOffice?: {
__typename?: 'Location'
name?: string | null
id: string
} | null
name: Array<{
__typename?: 'HumanName'
firstNames?: string | null
familyName?: string | null
use?: string | null
}>
avatar?: {
__typename?: 'Avatar'
type: string
data: string
} | null
} | null
}>
}

export type RegistrationsListByTimeFilter = {
__typename: 'TotalMetricsByTime'
total?: number | null
results: Array<{
__typename?: 'EventMetricsByTime'
total: number
delayed: number
late: number
home: number
healthFacility: number
month: string
time: string
}>
}

export type GetRegistrationsListByFilterQuery = {
__typename?: 'Query'
getRegistrationsListByFilter?:
| RegistrationsListByLocationFilter
| RegistrationsListByRegistrarFilter
| RegistrationsListByTimeFilter
| {
__typename: 'TotalMetricsByLocation'
total?: number | null
results: Array<{
__typename?: 'EventMetricsByLocation'
total: number
late: number
delayed: number
home: number
healthFacility: number
location: { __typename?: 'Location'; name?: string | null }
}>
}
| {
__typename: 'TotalMetricsByRegistrar'
total?: number | null
results: Array<{
__typename?: 'EventMetricsByRegistrar'
total: number
late: number
delayed: number
registrarPractitioner?: {
__typename?: 'User'
id: string
systemRole: SystemRoleType
role: {
__typename?: 'Role'
_id: string
labels: Array<{
__typename?: 'RoleLabel'
lang: string
label: string
}>
}
primaryOffice?: {
__typename?: 'Location'
name?: string | null
id: string
} | null
name: Array<{
__typename?: 'HumanName'
firstNames?: string | null
familyName?: string | null
use?: string | null
}>
avatar?: {
__typename?: 'Avatar'
type: string
data: string
} | null
} | null
}>
}
| {
__typename: 'TotalMetricsByTime'
total?: number | null
results: Array<{
__typename?: 'EventMetricsByTime'
total: number
delayed: number
late: number
home: number
healthFacility: number
month: string
time: string
}>
}
| null
}

Expand Down
18 changes: 12 additions & 6 deletions packages/client/src/views/Performance/RegistrationsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ import { IStoreState } from '@client/store'
import {
GetRegistrationsListByFilterQuery,
QueryGetRegistrationsListByFilterArgs,
RegistrationsListByLocationFilter,
RegistrationsListByRegistrarFilter,
RegistrationsListByTimeFilter,
RegistrationType
} from '@client/utils/gateway'
import { generateLocations } from '@client/utils/locationUtils'
Expand Down Expand Up @@ -398,7 +395,10 @@ function RegistrationListComponent(props: IProps) {
}

const getTableContentByRegistrar = (
result: RegistrationsListByRegistrarFilter['results'][0],
result: Extract<
GetRegistrationsListByFilterQuery['getRegistrationsListByFilter'],
{ __typename: 'TotalMetricsByRegistrar' }
>['results'][0],
index: number
) => ({
...result,
Expand Down Expand Up @@ -463,7 +463,10 @@ function RegistrationListComponent(props: IProps) {
})

const getTableContentByLocation = (
result: RegistrationsListByLocationFilter['results'][0],
result: Extract<
GetRegistrationsListByFilterQuery['getRegistrationsListByFilter'],
{ __typename: 'TotalMetricsByLocation' }
>['results'][0],
index: number
) => ({
...result,
Expand All @@ -485,7 +488,10 @@ function RegistrationListComponent(props: IProps) {
})

const getTableContentByTime = (
result: RegistrationsListByTimeFilter['results'][0],
result: Extract<
GetRegistrationsListByFilterQuery['getRegistrationsListByFilter'],
{ __typename: 'TotalMetricsByTime' }
>['results'][0],
index: number
) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { AppStore } from '@client/store'
import { CompletenessRates } from '@client/views/SysAdmin/Performance/CompletenessRates'
import { EVENT_COMPLETENESS_RATES } from '@client/navigation/routes'
import {
HAS_CHILD_LOCATION,
FETCH_MONTH_WISE_EVENT_ESTIMATIONS
FETCH_MONTH_WISE_EVENT_ESTIMATIONS,
IS_LEAF_LEVEL_LOCATION
} from '@client/views/SysAdmin/Performance/queries'
import { waitForElement } from '@client/tests/wait-for-element'
import { stringify, parse } from 'query-string'
Expand All @@ -37,33 +37,12 @@ describe('Registraion Rates tests', () => {
const graphqlMocks = [
{
request: {
query: HAS_CHILD_LOCATION,
query: IS_LEAF_LEVEL_LOCATION,
variables: { parentId: '6e1f3bce-7bcb-4bf6-8e35-0d9facdf158b' }
},
result: {
data: {
hasChildLocation: {
id: 'd70fbec1-2b26-474b-adbc-bb83783bdf29',
type: 'ADMIN_STRUCTURE',
identifier: [
{
system: 'http://opencrvs.org/specs/id/geo-id',
value: '4194'
},
{
system: 'http://opencrvs.org/specs/id/bbs-code',
value: '11'
},
{
system: 'http://opencrvs.org/specs/id/jurisdiction-type',
value: 'UNION'
},
{
system: 'http://opencrvs.org/specs/id/a2i-internal-reference',
value: 'division=9&district=30&upazila=233&union=4194'
}
]
}
isLeafLevelLocation: true
}
}
},
Expand Down Expand Up @@ -233,33 +212,12 @@ describe('Registraion Rates error state tests', () => {
const graphqlMocks = [
{
request: {
query: HAS_CHILD_LOCATION,
query: IS_LEAF_LEVEL_LOCATION,
variables: { parentId: '6e1f3bce-7bcb-4bf6-8e35-0d9facdf158b' }
},
result: {
data: {
hasChildLocation: {
id: 'd70fbec1-2b26-474b-adbc-bb83783bdf29',
type: 'ADMIN_STRUCTURE',
identifier: [
{
system: 'http://opencrvs.org/specs/id/geo-id',
value: '4194'
},
{
system: 'http://opencrvs.org/specs/id/bbs-code',
value: '11'
},
{
system: 'http://opencrvs.org/specs/id/jurisdiction-type',
value: 'UNION'
},
{
system: 'http://opencrvs.org/specs/id/a2i-internal-reference',
value: 'division=9&district=30&upazila=233&union=4194'
}
]
}
isLeafLevelLocation: true
}
}
},
Expand Down
Loading
Loading