-
Notifications
You must be signed in to change notification settings - Fork 17
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
update mock load configuration logic #252
update mock load configuration logic #252
Conversation
Task linked: CU-86by1w64p JeMPI UI Configuration |
WalkthroughThe recent updates primarily involve changing the HTTP method for fetching configuration data from Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range and nitpick comments (1)
JeMPI_Apps/JeMPI_UI/src/services/apiRoutes.ts (1)
3-3
: Consider differentiating the endpoints for GET and POST configuration to avoid potential conflicts.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (10)
- JeMPI_Apps/JeMPI_UI/src/services/ApiClient.ts (1 hunks)
- JeMPI_Apps/JeMPI_UI/src/services/apiRoutes.ts (1 hunks)
- JeMPI_Apps/JeMPI_UI/src/services/mockBackend.ts (3 hunks)
- JeMPI_Apps/JeMPI_UI/src/services/mockData.ts (2 hunks)
- JeMPI_Apps/JeMPI_UI/src/test/customSearch/Settings.test.tsx (2 hunks)
- JeMPI_Apps/JeMPI_UI/src/test/settings/CommonSettings.test.tsx (1 hunks)
- JeMPI_Apps/JeMPI_UI/src/test/settings/GoldenRecordLists.test.tsx (1 hunks)
- JeMPI_Apps/JeMPI_UI/src/test/settings/UniqueToGR.test.tsx (1 hunks)
- JeMPI_Apps/JeMPI_UI/src/test/settings/UniqueToInteraction.test.tsx (1 hunks)
- JeMPI_Apps/JeMPI_UI/tests/services/configuration.test.ts (1 hunks)
Files skipped from review due to trivial changes (2)
- JeMPI_Apps/JeMPI_UI/src/test/settings/UniqueToGR.test.tsx
- JeMPI_Apps/JeMPI_UI/src/test/settings/UniqueToInteraction.test.tsx
Additional Context Used
Biome (22)
JeMPI_Apps/JeMPI_UI/src/services/ApiClient.ts (16)
77-77: The computed expression can be simplified without the use of a string literal.
256-274: This else clause can be omitted because previous branches break early.
365-365: Use === instead of ==.
== is only allowed when comparing againstnull
375-375: Do not use template literals if interpolation and special-character handling are not needed.
386-386: Use === instead of ==.
== is only allowed when comparing againstnull
401-401: Template literals are preferred over string concatenation.
1-1: All these imports are only used as types.
1-2: All these imports are only used as types.
2-3: All these imports are only used as types.
3-9: All these imports are only used as types.
9-10: All these imports are only used as types.
12-22: All these imports are only used as types.
22-28: All these imports are only used as types.
28-29: Some named imports are only used as types.
29-30: All these imports are only used as types.
32-33: All these imports are only used as types.
JeMPI_Apps/JeMPI_UI/src/services/mockData.ts (4)
1-1: All these imports are only used as types.
1-2: The default import is only used as a type.
2-3: All these imports are only used as types.
3-4: All these imports are only used as types.
JeMPI_Apps/JeMPI_UI/tests/services/configuration.test.ts (2)
5-6: All these imports are only used as types.
23-23: This let declares a variable that is only assigned once.
Additional comments not posted (7)
JeMPI_Apps/JeMPI_UI/src/test/settings/CommonSettings.test.tsx (1)
5-5
: Change in data source for tests is appropriate and improves maintainability.Also applies to: 10-10
JeMPI_Apps/JeMPI_UI/src/test/customSearch/Settings.test.tsx (1)
4-4
: Proper use of mock data and hooks to ensure isolated testing.Also applies to: 6-6, 34-34
JeMPI_Apps/JeMPI_UI/src/test/settings/GoldenRecordLists.test.tsx (1)
4-4
: Consistent use of mock data across test files enhances maintainability.Also applies to: 10-10
JeMPI_Apps/JeMPI_UI/src/services/mockBackend.ts (1)
66-66
: Correct update of mock setup to use GET for configuration fetching.Verification successful
The
fetchConfiguration
method inApiClient.ts
correctly uses the GET method to fetch configuration data, aligning with the updated mock setup.
JeMPI_Apps/JeMPI_UI/src/services/ApiClient.ts: async fetchConfiguration() { const { data } = await this.client.get<Configuration>(ROUTES.GET_CONFIGURATION); return data; }
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify integration of GET configuration with actual API calls. # Test: Search for the actual API call usage. Expect: Only occurances of the GET method. rg --type typescript $'fetchConfiguration'Length of output: 76
Script:
#!/bin/bash # Description: Verify integration of GET configuration with actual API calls. # Test: Search for the actual API call usage. Expect: Only occurrences of the GET method. rg 'fetchConfiguration' --glob '*.ts'Length of output: 370
Script:
#!/bin/bash # Description: Extract the implementation of fetchConfiguration from ApiClient.ts # Test: Retrieve the function definition to verify it uses the GET method. rg 'async fetchConfiguration' -A 10 --glob 'JeMPI_Apps/JeMPI_UI/src/services/ApiClient.ts'Length of output: 858
JeMPI_Apps/JeMPI_UI/src/services/mockData.ts (2)
336-514
: The expandedconfiguration
object is well-structured and detailed, which should enhance the testing capabilities for field and rule configurations.
Line range hint
515-527
: The export of themockData
object is correctly implemented, ensuring all mock data structures are available for import in other modules.JeMPI_Apps/JeMPI_UI/src/services/ApiClient.ts (1)
92-92
: The update to use a GET request infetchConfiguration
is correctly implemented and aligns with the new route configuration.
…Load-Configuration-Integration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (5)
JeMPI_Apps/JeMPI_UI/src/services/ApiClient.ts (5)
Line range hint
365-365
: Use strict equality comparison (===
) instead of loose equality (==
).- if (response.status == 200 && + if (response.status === 200 &&
Line range hint
375-375
: Avoid using template literals when not necessary.- throw new Error('Failed to updateGoldenRecord with error: ' + error) + throw new Error('Failed to updateGoldenRecord with error: ' + String(error))
Line range hint
386-386
: Use strict equality comparison (===
) instead of loose equality (==
).- if (response.status == 200) { + if (response.status === 200) {
Line range hint
401-401
: Prefer template literals for better readability and consistency.- throw new Error('Failed to updateGoldenRecord with error: ' + error) + throw new Error(`Failed to updateGoldenRecord with error: ${error}`)
Line range hint
1-33
: Optimize imports by using TypeScript'simport type
when imports are only used for type annotations.- import { AxiosInstance, AxiosRequestConfig } from 'axios' + import type { AxiosInstance, AxiosRequestConfig } from 'axios' - import { AuditTrail } from '../types/AuditTrail' + import type { AuditTrail } from '../types/AuditTrail' - import { FieldChangeReq, Fields } from '../types/Fields' + import type { FieldChangeReq, Fields } from '../types/Fields' - import { + import type { ApiSearchResponse, ApiSearchResult, CustomSearchQuery, SearchQuery } from '../types/SimpleSearch' - import { OAuthParams } from '../types/User' + import type { OAuthParams } from '../types/User' - import { + import type { NotificationResponse, Interaction, ExpandedGoldenRecordResponse, InteractionWithScore, NotificationRequest, LinkRequest, GoldenRecordCandidatesResponse, DashboardData } from 'types/BackendResponse' - import { + import type { GoldenRecord, AnyRecord, DemographicData, PatientRecord } from 'types/PatientRecord' - import { Notifications, NotificationState } from 'types/Notification' + import type { Notifications, NotificationState } from 'types/Notification' - import { Configuration } from 'types/Configuration' + import type { Configuration } from 'types/Configuration'
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- JeMPI_Apps/JeMPI_UI/src/services/ApiClient.ts (1 hunks)
- JeMPI_Apps/JeMPI_UI/src/services/apiRoutes.ts (1 hunks)
- JeMPI_Apps/JeMPI_UI/src/services/mockBackend.ts (3 hunks)
Files skipped from review as they are similar to previous changes (2)
- JeMPI_Apps/JeMPI_UI/src/services/apiRoutes.ts
- JeMPI_Apps/JeMPI_UI/src/services/mockBackend.ts
Additional Context Used
Biome (16)
JeMPI_Apps/JeMPI_UI/src/services/ApiClient.ts (16)
77-77: The computed expression can be simplified without the use of a string literal.
256-274: This else clause can be omitted because previous branches break early.
365-365: Use === instead of ==.
== is only allowed when comparing againstnull
375-375: Do not use template literals if interpolation and special-character handling are not needed.
386-386: Use === instead of ==.
== is only allowed when comparing againstnull
401-401: Template literals are preferred over string concatenation.
1-1: All these imports are only used as types.
1-2: All these imports are only used as types.
2-3: All these imports are only used as types.
3-9: All these imports are only used as types.
9-10: All these imports are only used as types.
12-22: All these imports are only used as types.
22-28: All these imports are only used as types.
28-29: Some named imports are only used as types.
29-30: All these imports are only used as types.
32-33: All these imports are only used as types.
Additional comments not posted (1)
JeMPI_Apps/JeMPI_UI/src/services/ApiClient.ts (1)
92-92
: Update to use GET request for fetching configuration aligns with RESTful best practices when retrieving data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range and nitpick comments (2)
JeMPI_Apps/JeMPI_UI/src/utils/helpers.ts (2)
Line range hint
64-64
: Consider specifying more precise types instead of usingany
.- export const decodeQueryString = <T>(queryString: string): any => { + export const decodeQueryString = <T>(queryString: string): T => {Also applies to: 82-82, 85-85
Line range hint
70-76
: Simplify theencodeQueryString
function by using template literals and removing unnecessary else clauses.- } else if (typeof val === 'object') { - return encodeQueryString(val, nesting + `${key}.`) - } else { - return [nesting + key, val] - .map(s => encodeURIComponent(s ? s.toString() : '')) - .join('=') - } + } else { + return typeof val === 'object' + ? encodeQueryString(val, `${nesting}${key}.`) + : `${nesting}${key}=${encodeURIComponent(val ? val.toString() : '')}`;
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- JeMPI_Apps/JeMPI_UI/src/pages/settings/Settings.tsx (1 hunks)
- JeMPI_Apps/JeMPI_UI/src/types/Configuration.ts (1 hunks)
- JeMPI_Apps/JeMPI_UI/src/utils/helpers.ts (2 hunks)
Additional Context Used
Biome (10)
JeMPI_Apps/JeMPI_UI/src/pages/settings/Settings.tsx (2)
2-3: The default import and some named imports are only used as types.
12-13: Some named imports are only used as types.
JeMPI_Apps/JeMPI_UI/src/utils/helpers.ts (8)
64-64: Unexpected any. Specify a different type.
70-76: This else clause can be omitted because previous branches break early.
71-71: Template literals are preferred over string concatenation.
72-76: This else clause can be omitted because previous branches break early.
82-82: Unexpected any. Specify a different type.
85-85: Unexpected any. Specify a different type.
1-1: All these imports are only used as types.
1-2: All these imports are only used as types.
Additional comments not posted (2)
JeMPI_Apps/JeMPI_UI/src/utils/helpers.ts (1)
32-33
: The updates to theConfiguration
interface and thegenerateId
function are correctly implemented to handle the renamed fields.Also applies to: 129-133
JeMPI_Apps/JeMPI_UI/src/pages/settings/Settings.tsx (1)
120-120
: The updates to component props inSettings.tsx
correctly reflect the renamed fields in theConfiguration
interface.Also applies to: 128-128
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- JeMPI_Apps/JeMPI_UI/tests/services/configuration.test.ts (1 hunks)
Additional Context Used
Biome (2)
JeMPI_Apps/JeMPI_UI/tests/services/configuration.test.ts (2)
5-6: All these imports are only used as types.
23-23: This let declares a variable that is only assigned once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range and nitpick comments (4)
JeMPI_Apps/JeMPI_UI/src/services/ApiClient.ts (4)
Line range hint
77-77
: Consider simplifying the computed expression in the request interceptor setup to enhance readability.- if (['post', 'patch', 'put', 'delete'].indexOf(method || '') !== -1) { + if (['post', 'patch', 'put', 'delete'].includes(method || '')) {
Line range hint
367-367
: Use strict equality checks (===
) instead of loose equality checks (==
) to avoid potential bugs due to type coercion.- if (response.status == 200) { + if (response.status === 200) {Also applies to: 388-388
Line range hint
377-377
: Avoid using template literals when there is no variable interpolation or special character handling required.- throw new Error(`Got response from server but not all authentication details were present. Failed to validate`); + throw new Error('Got response from server but not all authentication details were present. Failed to validate');
Line range hint
403-403
: Prefer using template literals for string concatenation to improve readability and maintainability.- throw new Error('Failed to updateGoldenRecord with error: ' + error) + throw new Error(`Failed to updateGoldenRecord with error: ${error}`)
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- JeMPI_Apps/JeMPI_UI/src/services/ApiClient.ts (1 hunks)
- JeMPI_Apps/JeMPI_UI/src/services/mockData.ts (2 hunks)
- JeMPI_Apps/JeMPI_UI/src/test/settings/GoldenRecordLists.test.tsx (1 hunks)
- JeMPI_Apps/JeMPI_UI/src/test/settings/UniqueToGR.test.tsx (1 hunks)
- JeMPI_Apps/JeMPI_UI/src/test/settings/UniqueToInteraction.test.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- JeMPI_Apps/JeMPI_UI/src/test/settings/GoldenRecordLists.test.tsx
- JeMPI_Apps/JeMPI_UI/src/test/settings/UniqueToGR.test.tsx
- JeMPI_Apps/JeMPI_UI/src/test/settings/UniqueToInteraction.test.tsx
Additional Context Used
Biome (20)
JeMPI_Apps/JeMPI_UI/src/services/ApiClient.ts (16)
77-77: The computed expression can be simplified without the use of a string literal.
258-276: This else clause can be omitted because previous branches break early.
367-367: Use === instead of ==.
== is only allowed when comparing againstnull
377-377: Do not use template literals if interpolation and special-character handling are not needed.
388-388: Use === instead of ==.
== is only allowed when comparing againstnull
403-403: Template literals are preferred over string concatenation.
1-1: All these imports are only used as types.
1-2: All these imports are only used as types.
2-3: All these imports are only used as types.
3-9: All these imports are only used as types.
9-10: All these imports are only used as types.
12-22: All these imports are only used as types.
22-28: All these imports are only used as types.
28-29: Some named imports are only used as types.
29-30: All these imports are only used as types.
32-33: All these imports are only used as types.
JeMPI_Apps/JeMPI_UI/src/services/mockData.ts (4)
1-1: All these imports are only used as types.
1-2: The default import is only used as a type.
2-3: All these imports are only used as types.
3-4: All these imports are only used as types.
Additional comments not posted (1)
JeMPI_Apps/JeMPI_UI/src/services/ApiClient.ts (1)
92-94
: The methodfetchConfiguration
has been updated to use a GET request instead of a POST request. This change aligns with RESTful best practices for fetching data.
} | ||
}, | ||
{ | ||
fieldName: 'gender', | ||
fieldType: 'String', | ||
source: { | ||
csvCol: 3 | ||
}, | ||
indexGoldenRecord: '@index(exact,trigram)', | ||
linkMetaData: { | ||
comparison: 'JARO_WINKLER_SIMILARITY', | ||
comparisonLevels: [0.92], | ||
m: 0.9468393, | ||
u: 0.4436446 | ||
} | ||
}, | ||
{ | ||
fieldName: 'dob', | ||
fieldType: 'String', | ||
source: { | ||
csvCol: 4 | ||
}, | ||
linkMetaData: { | ||
comparison: 'JARO_WINKLER_SIMILARITY', | ||
comparisonLevels: [0.92], | ||
m: 0.7856196, | ||
u: 0.0000465 | ||
} | ||
}, | ||
{ | ||
fieldName: 'city', | ||
fieldType: 'String', | ||
source: { | ||
csvCol: 5 | ||
}, | ||
indexGoldenRecord: '@index(trigram)', | ||
linkMetaData: { | ||
comparison: 'JARO_WINKLER_SIMILARITY', | ||
comparisonLevels: [0.92], | ||
m: 0.8445694, | ||
u: 0.0355741 | ||
} | ||
}, | ||
{ | ||
fieldName: 'phone_number', | ||
fieldType: 'String', | ||
source: { | ||
csvCol: 6 | ||
}, | ||
indexGoldenRecord: '@index(exact,trigram)', | ||
linkMetaData: { | ||
comparison: 'JARO_WINKLER_SIMILARITY', | ||
comparisonLevels: [0.92], | ||
m: 0.84085, | ||
u: 0.0000004 | ||
} | ||
}, | ||
{ | ||
fieldName: 'national_id', | ||
fieldType: 'String', | ||
source: { | ||
csvCol: 7 | ||
}, | ||
indexGoldenRecord: '@index(exact,trigram)', | ||
indexInteraction: '@index(exact,trigram)', | ||
linkMetaData: { | ||
comparison: 'JARO_WINKLER_SIMILARITY', | ||
comparisonLevels: [0.92], | ||
m: 0.8441029, | ||
u: 0.0000002 | ||
} | ||
} | ||
], | ||
rules: { | ||
link: { | ||
deterministic: [ | ||
{ | ||
vars: ['national_id'], | ||
text: 'eq(national_id)' | ||
}, | ||
{ | ||
vars: ['given_name', 'family_name', 'phone_number'], | ||
text: 'eq(given_name) and eq(family_name) and eq(phone_number)' | ||
} | ||
], | ||
probabilistic: [ | ||
{ | ||
vars: [ | ||
'given_name', | ||
'family_name', | ||
'city', | ||
'phone_number', | ||
'national_id' | ||
], | ||
text: 'match(given_name,3) and match(family_name,3) or match(given_name,3) and match(city,3) or match(family_name,3) and match(city,3) or match(phone_number,2) or match(national_id,3)' | ||
} | ||
] | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
The script output indicates that there are still references to the old field names uniqueInteractionFields
and uniqueGoldenRecordFields
in the following files:
JeMPI_Apps/JeMPI_UI/src/test/settings/UniqueToGR.test.tsx
JeMPI_Apps/JeMPI_UI/src/test/settings/UniqueToInteraction.test.tsx
These references need to be updated to match the new field names in the configuration object to avoid runtime errors.
- Update references to
uniqueInteractionFields
anduniqueGoldenRecordFields
in the identified files.
Analysis chain
The configuration object has been updated with new field names and structures to reflect the changes in the Configuration
interface. Ensure that all references to these fields in the application are updated accordingly to avoid runtime errors.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify all references to configuration fields match the new structure.
# Test: Search for old field names usage. Expect: No occurrences of old names.
rg --type typescript $'uniqueInteractionFields|uniqueGoldenRecordFields'
Length of output: 108
Script:
#!/bin/bash
# Description: Verify all references to configuration fields match the new structure.
# Test: Search for old field names usage. Expect: No occurrences of old names.
rg --type ts $'uniqueInteractionFields|uniqueGoldenRecordFields'
Length of output: 1020
Summary by CodeRabbit
New Features
Refactor
uniqueInteractionFields
toauxInteractionFields
anduniqueGoldenRecordFields
toauxGoldenRecordFields
for better clarity.Tests
Chores