]> git.evergreen-ils.org Git - Evergreen.git/blob - docs/TechRef/Circ/holds-go-home.txt
Fix various Traditional and holds-go-home best-hold sort orders
[Evergreen.git] / docs / TechRef / Circ / holds-go-home.txt
1 Holds Go Home
2 =============
3
4 Outline
5 -------
6
7 A copy prefers to fulfill a hold near its home when:
8
9     - The last event for a copy was NOT at home *and* ...
10     - The copy has not circulated from home within the defined period *and* ...
11     - The copy has neither departed from home by transit nor arrived at home
12       by transit within the defined period.
13
14 Definitions
15 -----------
16
17 In the preceding section, some terms are used that want explanation.
18
19 _Event_ refers to either a circulation or a transit related to a copy. An
20 event has only two qualities we care about: moment and place.
21
22     - When the event comes from a circulation, _moment_ is checkin_time if
23       we have it, otherwise xact_start. When the event comes from a transit,
24       moment is dest_recv_time if we have it, otherwise source_send_time.
25
26     - When the event comes from a circulation, _place_ is checkin_lib if we
27       have it, otherwise circ_lib.  When the event comes from a transit,
28       place is dest, *always*.
29
30     - When the copy in question has neither any transit history nor any
31       circulation history, we produce a synthetic event with _moment_ equal
32       to the present time, and _place_ equal to the copy's call number's
33       owning_lib (see 'home' below).
34
35 _Home_ is the value of the copy's call number's owning_lib field, which
36 incidentally is usually equal to the copy's circ_lib field except where
37 floating is in use.
38
39 _The defined period_ is the time between the present moment (_NOW()_
40 to the database) and the present moment less the value of the interval
41 defined in the _circ.hold_go_home_interval_ org unit setting at a scope
42 of the copy's _home_.  E.g., if the setting contains the string "6 months",
43 the defined period is the last 6 months before the present moment, or
44 anything greater than _NOW() - '6 months'::INTERVAL_.
45
46 Logic
47 -----
48
49 ............................................
50
51  -------
52 | Event |
53  -------
54    |
55    |
56    v
57  -------------------------                   -----------------------
58 | Was last event at home? | -----Yes.-----> | Don't try to go home. |
59  -------------------------                   -----------------------
60    |                                                      ^      ^
61    |  No.                                                 |      |
62    v                                                      |      |
63  ------------------------------------------------         |      |
64 | Did copy circ from home during defined period? |--Yes.--/      |
65  ------------------------------------------------                |
66    |                                                             |
67    |  No.                                                        |
68    |                                                             |
69    v                                                             |
70  ------------------------------------------------------          |
71 | Did copy leave or arrive home during defined period? |--Yes.---/
72  ------------------------------------------------------
73    |
74    |  No.
75    |
76    v
77  ----------
78 | Go home. |
79  ----------
80
81 ............................................
82
83
84 Implications in Best-Hold Selection Sort Order
85 ----------------------------------------------
86
87 The calculations described above are all embodied in the best-hold selection
88 sort order determinant _shtime_.
89
90 _htime_ is a simpler version of the same, with all reference to transits
91 removed, considering only circulations.  This means events become thin
92 circulations, the "Did a transit bring copy home..." step in the flow chart
93 goes away, etc. etc.