Skip to content

Commit

Permalink
#556 direct output to the log
Browse files Browse the repository at this point in the history
  • Loading branch information
dmcassel committed Sep 7, 2016
1 parent 4029279 commit cae5363
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/admin/controller/purge-previews.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@ ASSUMPTION: Each preview doc is stored in /preview, and its file name starts wit

let $today := current-date()
let $preview-docs := collection()/*[@preview-only eq 'yes']
let $deleted-docs := for $p in $preview-docs
return
let $uri := base-uri($p)
let $filename := substring-after($uri,"/preview/")
let $date := xs:date(substring($filename,1,10))
return
if ($date lt $today)
then ( xdmp:document-delete($uri), concat("Deleted: ",$uri, " ") )
else ()
let $deleted-docs :=
for $p in $preview-docs
let $uri := base-uri($p)
let $filename := substring-after($uri,"/preview/")
let $date := xs:date(substring($filename,1,10))
return
if ($date lt $today) then (
xdmp:document-delete($uri),
xdmp:log(concat("Deleted: ",$uri, " "))
)
else ()
return
(
if ($deleted-docs) then $deleted-docs else "All preview docs before today have already been purged."
if ($deleted-docs) then
$deleted-docs
else
xdmp:log("All preview docs before today have already been purged.")
)

0 comments on commit cae5363

Please sign in to comment.