Last active
March 6, 2018 14:16
-
-
Save eouthwaite/34b411417ef593eec146105b0ee0c4df to your computer and use it in GitHub Desktop.
Lazy way to grab all GitHub issues for MarkLogicWorkflow and convert to csv - the json document is stored in ML, so a larger report can be created if required
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
let $uri := "https://api.github.com/repos/marklogic-community/marklogicworkflow/issues?state=all&per_page=200" | |
let $result := xdmp:http-get($uri) | |
return | |
xdmp:document-insert("/marklogic-community/marklogicworkflow/issues.json", $result[2]) | |
; | |
import module namespace json = "http://marklogic.com/xdmp/json" at "/MarkLogic/json/json.xqy"; | |
declare namespace jbas = "http://marklogic.com/xdmp/json/basic"; | |
('"number", "title", "state", "sprint", "assignee", "state", "label(s)", "notes"', | |
let $issues := doc("/marklogic-community/marklogicworkflow/issues.json") | |
let $xissues := json:transform-from-json($issues) | |
for $issue in $xissues/jbas:json | |
return ( | |
fn:string-join(( | |
xs:string($issue/jbas:number), | |
fn:concat('"', xs:string($issue/jbas:title), '"'), | |
fn:concat('"', xs:string($issue/jbas:state), '"'), | |
fn:concat('"', ( | |
if ((fn:exists($issue/jbas:milestone[@type="null"])) and (fn:exists($issue/jbas:state[xs:string(.)="open"]))) | |
then "BACKLOG" | |
else xs:string($issue/jbas:milestone/jbas:title) | |
), '"'), | |
fn:concat('"', ( | |
if (fn:exists($issue/jbas:assignee[@type="null"])) | |
then "" | |
else xs:string($issue/jbas:assignee/jbas:login) | |
), '"'), | |
fn:concat('"', ( | |
if (fn:exists($issue/jbas:labels/jbas:json/jbas:name[xs:string(.)="inprogress"])) | |
then "In Progress" | |
else "" | |
), '"'), | |
fn:concat('"', ( | |
if (fn:exists($issue/jbas:labels/jbas:json/jbas:name[xs:string(.)!="inprogress"])) | |
then fn:string-join(($issue/jbas:labels/jbas:json/jbas:name/xs:string(.)[.!="inprogress"]), ";") | |
else "" | |
), '"'), | |
fn:concat('"', " ", '"') | |
), ",") | |
(: , $issue :) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment