-
Notifications
You must be signed in to change notification settings - Fork 4
[NAE-2451] Optimize and Reduce Outcome Size #342
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
base: release/7.0.2
Are you sure you want to change the base?
Changes from all commits
e1f1994
d2daede
85f318e
dcd9626
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 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -61,8 +61,12 @@ export class TaskResourceService extends AbstractResourceService implements Coun | |||||||||||||||||||||||||
| * GET | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| // {{baseUrl}}/api/task/assign/:id | ||||||||||||||||||||||||||
| public assignTask(taskId: string): Observable<EventOutcomeMessageResource> { | ||||||||||||||||||||||||||
| return this._resourceProvider.get$('task/assign/' + taskId, this.SERVER_URL) | ||||||||||||||||||||||||||
| public assignTask(taskId: string, params?: HttpParams): Observable<EventOutcomeMessageResource> { | ||||||||||||||||||||||||||
| if (!params) { | ||||||||||||||||||||||||||
| params = new HttpParams(); | ||||||||||||||||||||||||||
| params = params.set('fields', 'outcomes,outcome,task(stringId)'); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| return this._resourceProvider.get$('task/assign/' + taskId, this.SERVER_URL, params) | ||||||||||||||||||||||||||
| .pipe(map(r => this.changeType(r, undefined))); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -71,8 +75,12 @@ export class TaskResourceService extends AbstractResourceService implements Coun | |||||||||||||||||||||||||
| * GET | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| // {{baseUrl}}/api/task/cancel/:id | ||||||||||||||||||||||||||
| public cancelTask(taskId: string): Observable<EventOutcomeMessageResource> { | ||||||||||||||||||||||||||
| return this._resourceProvider.get$('task/cancel/' + taskId, this.SERVER_URL) | ||||||||||||||||||||||||||
| public cancelTask(taskId: string, params?: Params): Observable<EventOutcomeMessageResource> { | ||||||||||||||||||||||||||
| if (!params) { | ||||||||||||||||||||||||||
| params = new HttpParams(); | ||||||||||||||||||||||||||
| params = params.set('fields', 'outcomes,outcome,task(stringId)'); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| return this._resourceProvider.get$('task/cancel/' + taskId, this.SERVER_URL, params) | ||||||||||||||||||||||||||
| .pipe(map(r => this.changeType(r, undefined))); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -81,8 +89,12 @@ export class TaskResourceService extends AbstractResourceService implements Coun | |||||||||||||||||||||||||
| * POST | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| // {{baseUrl}}/api/task/delegate/:id | ||||||||||||||||||||||||||
| public delegateTask(taskId: string, body: object): Observable<EventOutcomeMessageResource> { | ||||||||||||||||||||||||||
| return this._resourceProvider.post$('task/delegate/' + taskId, this.SERVER_URL, body, undefined, {'Content-Type': 'text/plain'}) | ||||||||||||||||||||||||||
| public delegateTask(taskId: string, body: object, params?: HttpParams): Observable<EventOutcomeMessageResource> { | ||||||||||||||||||||||||||
| if (!params) { | ||||||||||||||||||||||||||
| params = new HttpParams(); | ||||||||||||||||||||||||||
| params = params.set('fields', 'outcomes,outcome,task(stringId)'); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| return this._resourceProvider.post$('task/delegate/' + taskId, this.SERVER_URL, body, params, {'Content-Type': 'text/plain'}) | ||||||||||||||||||||||||||
| .pipe(map(r => this.changeType(r, undefined))); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -91,8 +103,12 @@ export class TaskResourceService extends AbstractResourceService implements Coun | |||||||||||||||||||||||||
| * GET | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| // {{baseUrl}}/api/task/finish/:id | ||||||||||||||||||||||||||
| public finishTask(taskId: string): Observable<EventOutcomeMessageResource> { | ||||||||||||||||||||||||||
| return this._resourceProvider.get$('task/finish/' + taskId, this.SERVER_URL) | ||||||||||||||||||||||||||
| public finishTask(taskId: string, params?: Params): Observable<EventOutcomeMessageResource> { | ||||||||||||||||||||||||||
| if (!params) { | ||||||||||||||||||||||||||
| params = new HttpParams(); | ||||||||||||||||||||||||||
| params = params.set('fields', 'outcomes,outcome,task(stringId)'); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| return this._resourceProvider.get$('task/finish/' + taskId, this.SERVER_URL, params) | ||||||||||||||||||||||||||
| .pipe(map(r => this.changeType(r, undefined))); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -187,8 +203,12 @@ export class TaskResourceService extends AbstractResourceService implements Coun | |||||||||||||||||||||||||
| * @returns the raw backend response without any additional processing | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| // {{baseUrl}}/api/task/:id/data | ||||||||||||||||||||||||||
| public rawGetData(taskId: string): Observable<EventOutcomeMessageResource> { | ||||||||||||||||||||||||||
| return this._resourceProvider.get$('task/' + taskId + '/data', this.SERVER_URL) | ||||||||||||||||||||||||||
| public rawGetData(taskId: string, params?: Params): Observable<EventOutcomeMessageResource> { | ||||||||||||||||||||||||||
| if (!params) { | ||||||||||||||||||||||||||
| params = new HttpParams(); | ||||||||||||||||||||||||||
| params = params.set('fields', 'outcomes,task(stringId),data'); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| return this._resourceProvider.get$('task/' + taskId + "/data", this.SERVER_URL, params) | ||||||||||||||||||||||||||
|
Comment on lines
+206
to
+211
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. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Request When Proposed fix- params = params.set('fields', 'outcomes,task(stringId),data');
+ params = params.set('fields', 'outcomes,outcome,task(stringId),data');📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| .pipe(map(r => this.changeType(r, undefined))); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -200,10 +220,11 @@ export class TaskResourceService extends AbstractResourceService implements Coun | |||||||||||||||||||||||||
| * If you want to process the raw backend response use [rawGetData]{@link TaskResourceService#rawGetData} instead. | ||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||
| * @param taskId ID of the task who's data should be retrieved from the server | ||||||||||||||||||||||||||
| * @param params HTTP params | ||||||||||||||||||||||||||
| * @returns processed data groups of the given task. If the task has no data an empty array will be returned. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| public getData(taskId: string): Observable<Array<DataGroup>> { | ||||||||||||||||||||||||||
| return this.rawGetData(taskId).pipe( | ||||||||||||||||||||||||||
| public getData(taskId: string, params?: Params): Observable<Array<DataGroup>> { | ||||||||||||||||||||||||||
| return this.rawGetData(taskId, params).pipe( | ||||||||||||||||||||||||||
| map((responseOutcome: EventOutcomeMessageResource) => { | ||||||||||||||||||||||||||
| if (responseOutcome.error) { | ||||||||||||||||||||||||||
| throw new Error(responseOutcome.error); | ||||||||||||||||||||||||||
|
|
@@ -253,8 +274,12 @@ export class TaskResourceService extends AbstractResourceService implements Coun | |||||||||||||||||||||||||
| * POST | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| // {{baseUrl}}/api/task/:id/data | ||||||||||||||||||||||||||
| public setData(taskId: string, body: TaskSetDataRequestBody): Observable<EventOutcomeMessageResource> { | ||||||||||||||||||||||||||
| return this._resourceProvider.post$('task/' + taskId + '/data', this.SERVER_URL, body) | ||||||||||||||||||||||||||
| public setData(taskId: string, body: TaskSetDataRequestBody, params?: Params): Observable<EventOutcomeMessageResource> { | ||||||||||||||||||||||||||
| if (!params) { | ||||||||||||||||||||||||||
| params = new HttpParams(); | ||||||||||||||||||||||||||
| params = params.set('fields', 'outcomes,outcome,case(stringId),task(stringId),changedFields'); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| return this._resourceProvider.post$('task/' + taskId + "/data", this.SERVER_URL, body, params) | ||||||||||||||||||||||||||
| .pipe(map(r => this.changeType(r, undefined))); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
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.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Test the omitted-parameter behavior.
Every changed test supplies
new HttpParams(). That bypasses the new default projection branch. Add no-parameter tests that assert the expectedfieldsparameter.projects/netgrif-components-core/src/lib/resources/engine-endpoint/case-resource.service.spec.ts#L78-L78: calldeleteCasewithoutHttpParamsand assert its default projection.projects/netgrif-components-core/src/lib/resources/engine-endpoint/case-resource.service.spec.ts#L116-L116: callcreateCasewithoutHttpParamsand assert its default projection.projects/netgrif-components-core/src/lib/resources/engine-endpoint/task-resource.service.spec.ts#L61-L61: callassignTaskwithoutHttpParamsand assert its default projection.projects/netgrif-components-core/src/lib/resources/engine-endpoint/task-resource.service.spec.ts#L77-L77: callcancelTaskwithoutHttpParamsand assert its default projection.projects/netgrif-components-core/src/lib/resources/engine-endpoint/task-resource.service.spec.ts#L93-L93: calldelegateTaskwithoutHttpParamsand assert its default projection.projects/netgrif-components-core/src/lib/resources/engine-endpoint/task-resource.service.spec.ts#L109-L109: callfinishTaskwithoutHttpParamsand assert its default projection.projects/netgrif-components-core/src/lib/resources/engine-endpoint/task-resource.service.spec.ts#L221-L221: callgetDatawithoutHttpParamsand assert its default projection.projects/netgrif-components-core/src/lib/resources/engine-endpoint/task-resource.service.spec.ts#L246-L246: callsetDatawithoutHttpParamsand assert its default projection.📍 Affects 2 files
projects/netgrif-components-core/src/lib/resources/engine-endpoint/case-resource.service.spec.ts#L78-L78(this comment)projects/netgrif-components-core/src/lib/resources/engine-endpoint/case-resource.service.spec.ts#L116-L116projects/netgrif-components-core/src/lib/resources/engine-endpoint/task-resource.service.spec.ts#L61-L61projects/netgrif-components-core/src/lib/resources/engine-endpoint/task-resource.service.spec.ts#L77-L77projects/netgrif-components-core/src/lib/resources/engine-endpoint/task-resource.service.spec.ts#L93-L93projects/netgrif-components-core/src/lib/resources/engine-endpoint/task-resource.service.spec.ts#L109-L109projects/netgrif-components-core/src/lib/resources/engine-endpoint/task-resource.service.spec.ts#L221-L221projects/netgrif-components-core/src/lib/resources/engine-endpoint/task-resource.service.spec.ts#L246-L246🤖 Prompt for AI Agents