-
Notifications
You must be signed in to change notification settings - Fork 0
CROSSLINK-210 Add more search parameters #434
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: main
Are you sure you want to change the base?
Changes from all commits
80dd56f
fe98b2d
4cbc7a0
aed026c
31be812
5d4d45a
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| DROP VIEW patron_request_search_view ; | ||
|
|
||
| ALTER TABLE patron_request DROP COLUMN needs_attention; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| ALTER TABLE patron_request ADD COLUMN needs_attention BOOLEAN NOT NULL DEFAULT false; | ||
|
|
||
| CREATE OR REPLACE VIEW patron_request_search_view AS | ||
| SELECT | ||
| pr.*, | ||
| EXISTS ( | ||
| SELECT 1 | ||
| FROM notification n | ||
| WHERE n.pr_id = pr.id | ||
| ) AS has_notification, | ||
| EXISTS ( | ||
| SELECT 1 | ||
| FROM notification n | ||
| WHERE n.pr_id = pr.id and cost is not null | ||
| ) AS has_cost, | ||
| EXISTS ( | ||
| SELECT 1 | ||
| FROM notification n | ||
| WHERE n.pr_id = pr.id and acknowledged_at is null | ||
| ) AS has_unread_notification, | ||
| pr.ill_request -> 'serviceInfo' ->> 'serviceType' AS service_type, | ||
| pr.ill_request -> 'serviceInfo' -> 'serviceLevel' ->> '#text' AS service_level, | ||
| (pr.ill_request -> 'serviceInfo' ->> 'needBeforeDate')::timestamptz AS needed_at | ||
| FROM patron_request pr; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -120,6 +120,9 @@ func (a *PatronRequestActionService) finalizeActionExecution(ctx common.Extended | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if execResult.outcome == ActionOutcomeFailure { | ||||||||||||||||||||||||||||||
| a.setNeedsAttention(ctx, updatedPr) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| return execResult.status, execResult.result | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -607,6 +610,19 @@ func (a *PatronRequestActionService) checkSupplyingResponse(status events.EventS | |||||||||||||||||||||||||||||
| return actionExecutionResult{status: events.EventStatusSuccess, result: nil, outcome: ActionOutcomeSuccess, pr: pr} | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| func (a *PatronRequestActionService) setNeedsAttention(ctx common.ExtendedContext, pr pr_db.PatronRequest) { | ||||||||||||||||||||||||||||||
| prToUpdate, err := a.prRepo.GetPatronRequestById(ctx, pr.ID) | ||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||
| ctx.Logger().Error("failed to read patron request", "error", err) | ||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| prToUpdate.NeedsAttention = true | ||||||||||||||||||||||||||||||
| _, err = a.prRepo.UpdatePatronRequest(ctx, pr_db.UpdatePatronRequestParams(prToUpdate)) | ||||||||||||||||||||||||||||||
|
Comment on lines
+614
to
+620
|
||||||||||||||||||||||||||||||
| prToUpdate, err := a.prRepo.GetPatronRequestById(ctx, pr.ID) | |
| if err != nil { | |
| ctx.Logger().Error("failed to read patron request", "error", err) | |
| return | |
| } | |
| prToUpdate.NeedsAttention = true | |
| _, err = a.prRepo.UpdatePatronRequest(ctx, pr_db.UpdatePatronRequestParams(prToUpdate)) | |
| if pr.NeedsAttention { | |
| // Already marked; avoid unnecessary update. | |
| return | |
| } | |
| pr.NeedsAttention = true | |
| _, err := a.prRepo.UpdatePatronRequest(ctx, pr_db.UpdatePatronRequestParams(pr)) |
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.
The new
patron_request_search_viewcomputeshas_notification/has_cost/has_unread_notificationvia correlatedEXISTSsubqueries onnotification. There doesn’t appear to be an index onnotification.pr_id, so these checks can degrade list performance significantly (especially with large offsets). Consider addingCREATE INDEXonnotification(pr_id)and (optionally) partial indexes for thecost IS NOT NULLandacknowledged_at IS NULLpredicates.