Comment 2 for bug 1164132

Revision history for this message
Jason Etheridge (phasefx) wrote :

For a test, I took stock master and the stock test data, and then... noticed that hold with id = 1 has 0 potential copies and the bib that it is targeting has no other holds; so before changing any data or code, for reference:

srfsh# request open-ils.circ open-ils.circ.hold.queue_stats.retrieve "d69b0fb71e025dd509bdc13963da974b" 1

Received Data: {
  "potential_copies":0,
  "status":1,
  "total_holds":1,
  "queue_position":1,
  "estimated_wait":-1
}

Then I made a near duplicate yet cancelled hold:
evergreen2=# insert into action.hold_request (cancel_time, cancel_cause, target, request_lib, requestor, usr, selection_ou, pickup_lib, hold_type) select now(), 5, target, request_lib, requestor, usr, selection_ou, pickup_lib, hold_type from action.hold_request where id = 1;
UPDATE 1

And that incorrectly changed the total_holds reported, but not the queue_position:
srfsh# request open-ils.circ open-ils.circ.hold.queue_stats.retrieve "d69b0fb71e025dd509bdc13963da974b" 1

Received Data: {
  "potential_copies":0,
  "status":1,
  "total_holds":2,
  "queue_position":1,
  "estimated_wait":-1
}

So I changed the request_time on the hold I just created to something before its peer hold:
evergreen2=# update action.hold_request set request_time = (select min(request_time) from action.hold_request) - '1 month'::interval where id = (select max(id) from action.hold_request);
UPDATE 1

And that did the trick:
srfsh# request open-ils.circ open-ils.circ.hold.queue_stats.retrieve "d69b0fb71e025dd509bdc13963da974b" 1

Received Data: {
  "potential_copies":0,
  "status":1,
  "total_holds":2,
  "queue_position":2,
  "estimated_wait":-1
}

And then I put in Bill's patch and restarted services:
srfsh# request open-ils.circ open-ils.circ.hold.queue_stats.retrieve "d69b0fb71e025dd509bdc13963da974b" 1

Received Data: {
  "potential_copies":0,
  "status":1,
  "total_holds":1,
  "queue_position":1,
  "estimated_wait":-1
}

Signed off at collab/phasefx/lp1164132-hold-queue-ignore-canceled and pushed to master. I don't have the big picture anymore for the other branches and how they're maintained