Skip to content

Commit 751b98c

Browse files
committed
add jubilee and persons query
1 parent 07c0a1a commit 751b98c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

modules/api.xqm

+11-7
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ declare function api:documents-findByAuthor($model as map(*)) as map(*) {
109109
};
110110

111111
declare function api:documents-otd($model as map(*)) as map(*) {
112-
let $date :=
112+
let $dateWithoutYear :=
113+
(: strip of the year part so only month and day are left, e.g. "12-03" :)
113114
if($model?date castable as xs:date)
114115
then $model?date => substring(6, 5)
115116
else current-date() => substring(6, 5)
@@ -120,9 +121,13 @@ declare function api:documents-otd($model as map(*)) as map(*) {
120121
case 'letters' return
121122
core:getOrCreateColl(
122123
$docType,'indices', true()
123-
)//tei:TEI[ft:query(., 'date:' || $date)]//tei:correspAction[@type='sent']/tei:date[contains(@when, $date)][following::tei:text//tei:p]
124-
(: case 'persons' return:)
125-
(: core:getOrCreateColl($docType, 'indices', true())//tei:date[contains(@when, $month-day)][not(preceding-sibling::tei:date[contains(@when, $month-day)])][parent::tei:birth or parent::tei:death][ancestor::tei:person/@source='WeGA']:)
124+
)//tei:TEI[ft:query(., 'date:' || $dateWithoutYear)]//tei:correspAction[@type='sent']/tei:date
125+
[contains(@when, $dateWithoutYear)][following::tei:text//tei:p]
126+
case 'persons' return
127+
core:getOrCreateColl(
128+
$docType, 'indices', true()
129+
)//tei:person[ft:query(., 'date:' || $dateWithoutYear, map{'facets': map{'docSource': 'WeGA'}})]
130+
//tei:date[contains(@when, $dateWithoutYear)][parent::tei:birth or parent::tei:death]
126131
default return ()
127132
return (
128133
map {
@@ -571,13 +576,12 @@ declare %private function api:document-otd($dateElements as element(tei:date)*,
571576
else if($dateElem[@type='funeral']) then 'wasBuried'
572577
else if($dateElem/parent::tei:death) then 'dies'
573578
else ()
574-
let $isJubilee := (year-from-date($model?date) - $dateElem/year-from-date(@when)) mod 25 = 0
579+
let $jubilee := year-from-date($model?date) - $dateElem/year-from-date(@when)
575580
return map:merge((
576581
api:document-basics($dateElem/root(), $docID, $docType, $model),
577582
map {
578-
'otdTitle': '',
579583
'otdEvent': $typeOfEvent,
580-
'otdJubilee': ''
584+
'otdJubilee': $jubilee
581585
}
582586
))
583587
}

0 commit comments

Comments
 (0)