-
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
Added matching rule to audit trail table #181
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { AxiosInstance, AxiosRequestConfig } from 'axios' | ||
import { AuditTrailEntries } from '../types/AuditTrail' | ||
import { AuditTrailEntries, ExpandedAuditTrail } from '../types/AuditTrail' | ||
import { FieldChangeReq, Fields } from '../types/Fields' | ||
import { | ||
ApiSearchResponse, | ||
|
@@ -343,6 +343,24 @@ export class ApiClient { | |
})) | ||
} | ||
|
||
async getExpandedGoldenRecordAuditTrail(gid: string): Promise<ExpandedAuditTrail[]>{ | ||
const entries = await this.getGoldenRecordAuditTrail(gid); | ||
|
||
return entries.map((entry) => { | ||
const expandedEntry: ExpandedAuditTrail = { | ||
matching_rule: extractMatchingRule(entry.entry), | ||
inserted_at: entry.inserted_at, | ||
created_at: entry.created_at, | ||
interaction_id: entry.interaction_id, | ||
golden_id: entry.golden_id, | ||
entry: entry.entry | ||
|
||
}; | ||
|
||
return expandedEntry; | ||
}) | ||
} | ||
|
||
async getGoldenRecordAuditTrail(gid: string) { | ||
const { | ||
data: { entries } | ||
|
@@ -357,6 +375,24 @@ export class ApiClient { | |
return entries | ||
} | ||
|
||
async getExpandedInteractionAuditTrail(iid: string): Promise<ExpandedAuditTrail[]>{ | ||
const entries = await this.getInteractionAuditTrail(iid); | ||
|
||
return entries.map((entry) => { | ||
const expandedEntry: ExpandedAuditTrail = { | ||
matching_rule: null, | ||
inserted_at: entry.inserted_at, | ||
created_at: entry.created_at, | ||
interaction_id: entry.interaction_id, | ||
golden_id: entry.golden_id, | ||
entry: entry.entry | ||
|
||
}; | ||
|
||
return expandedEntry; | ||
}) | ||
} | ||
|
||
async getInteractionAuditTrail(iid: string) { | ||
const { | ||
data: { entries } | ||
|
@@ -419,6 +455,35 @@ export class ApiClient { | |
} | ||
} | ||
|
||
const extractMatchingRule = (input: string ) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not the correct way of doing this. As much as possible avoid using heuristic for your logic...i.e assuming the string will always be of a particular format , or if the score is x then it is What you want to do is send back this data with the correct info already, removing the need to use heuristic. i.e [
{
"text": "Matched with score....etc",
"matchType": "DETERMINISTIC"
}
] and then extract the information from there |
||
const numberStr = extractScore(input) | ||
|
||
if (numberStr !== null) { | ||
const number = parseFloat(numberStr); | ||
|
||
if (number === 1.0) { | ||
return "DETERMINISTIC"; | ||
} else if (number > 0.0 && number < 1.0) { | ||
return "PROBABILISTIC"; | ||
} | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
const extractScore = (input: string) => { | ||
const pattern = /\((\d+\.\d+)\)/; | ||
const matches = input.match(pattern); | ||
|
||
if (matches !== null) { | ||
return matches[1]; | ||
} else { | ||
return null; | ||
} | ||
}; | ||
|
||
|
||
|
||
const apiClient = new ApiClient() | ||
|
||
export function getApiClient(config: Config) { | ||
|
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.
I dont think you should create a new type. The change is too small (i.e not worth the extra complexities) . Just update the current version of the
AuditTrail
type with the additional type.