Commit dc73a1bc authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

tg status implementation

parent 69d4053a
......@@ -423,20 +423,19 @@ switch ($develop)
};
declare function f-misc:textgridStatus($node as node(), $model as map(*)) {
let $col := "/db/sade-projects/textgrid"
let $res := "tgstatus.xml"
let $url := "https://dariah-de.github.io/status/textgrid/repstatus.html"
let $lastMod := xmldb:last-modified($col, $res)
let $path := $col || "/" || $res
let $doc := doc( $path )
let $active := not( exists( $doc//ok ) )
let $needlookup := ( not(doc-available( $path )) or $lastMod < (current-dateTime() - xs:dayTimeDuration("PT12H")) )
let $getStatus :=
if( $needlookup )
then
let $col := "/db/sade-projects/textgrid"
let $res := "tgstatus.xml"
let $url := "https://dariah-de.github.io/status/textgrid/repstatus.html"
let $lastMod := xmldb:last-modified($col, $res)
let $path := $col || "/" || $res
let $doc := doc( $path )
let $active := not( exists( $doc//ok ) )
let $needUpdate := not(doc-available($path)) or $lastMod < (current-dateTime() - xs:dayTimeDuration("PT12H"))
let $getStatus :=
if( $needUpdate )
then
let $status := httpclient:get(xs:anyURI($url), false(), ())//xhtml:div[contains(@class, 'repstatus')][not( contains(@class, 'ok') )]
let $status := if( exists( $status ) ) then $status else <ok/>
let $console := console:log( $status )
return
xmldb:store($col, $res, $status)
else if($active and $lastMod < (current-dateTime() - xs:dayTimeDuration("PT2H")))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment