improve issues component by showcasing links between issues #46

Open
opened 2 years ago by utopiah · 5 comments
Owner
There is no content yet.
Poster
Owner

example of getting issues mentioned in the issue itself (not follow up comments)

fetch("https://git.benetou.fr/api/v1/repos/utopiah/text-code-xr-engine/issues")
  .then( res => res.json() )
  .then( res => { 
	console.log( res.filter( i => i.number == 48)
        .map( i => i.body.split("http")
             .filter( l => l.indexOf("://git.benetou.fr/utopiah/text-code-xr-engine/issues/")>0 ) 
             .map( l => l.replace(/.*\issues\/(\d+)\D*/, (str,id) => id ) )
            )
   )
} )
example of getting issues mentioned in the issue itself (not follow up comments) ```javascript fetch("https://git.benetou.fr/api/v1/repos/utopiah/text-code-xr-engine/issues") .then( res => res.json() ) .then( res => { console.log( res.filter( i => i.number == 48) .map( i => i.body.split("http") .filter( l => l.indexOf("://git.benetou.fr/utopiah/text-code-xr-engine/issues/")>0 ) .map( l => l.replace(/.*\issues\/(\d+)\D*/, (str,id) => id ) ) ) ) } ) ```
Poster
Owner

example of showing all issues with links to other issues (again just in issue itself, not comments)

fetch("https://git.benetou.fr/api/v1/repos/utopiah/text-code-xr-engine/issues")
  .then( res => res.json() )
  .then( res => {
      console.log( res.filter( i => i.number )
        .map( i => i.body.split("http")
             .filter( l => l.indexOf("://git.benetou.fr/utopiah/text-code-xr-engine/issues/")>0 ) 
             .map( l => { return { source : i.id, target: l.replace(/.*\issues\/(\d+)\D*/, (str,id) => id ) } } )
            ).filter( i => i.length > 0)
	)
} )

example of showing all issues with links to other issues (again just in issue itself, not comments) ```javascript fetch("https://git.benetou.fr/api/v1/repos/utopiah/text-code-xr-engine/issues") .then( res => res.json() ) .then( res => { console.log( res.filter( i => i.number ) .map( i => i.body.split("http") .filter( l => l.indexOf("://git.benetou.fr/utopiah/text-code-xr-engine/issues/")>0 ) .map( l => { return { source : i.id, target: l.replace(/.*\issues\/(\d+)\D*/, (str,id) => id ) } } ) ).filter( i => i.length > 0) ) } ) ```
Poster
Owner

example for all issues with all their comments

fetch("https://git.benetou.fr/api/v1/repos/utopiah/text-code-xr-engine/issues")
  .then( res => res.json() )
  .then( res => { 
  	 var nodes = {}
     res.map( i => {
        if (body2ids(i.body).length > 0) nodes[i.id]=body2ids(i.body)
        
        fetch("https://git.benetou.fr/api/v1/repos/utopiah/text-code-xr-engine/issues/"+i.id+"/comments")
          .then( res => res.json() )
          .then( c => {
            if (c.length ) c.map( comm => {
              if (body2ids( comm.body ).length>0)
               if (nodes[i.id])
                 nodes[i.id] =  [...new Set( nodes[i.id].concat( body2ids( comm.body )) )]
               else 
                 nodes[i.id] = body2ids( comm.body )
            } )
        	})
      } )
  console.log(nodes)
} )

function body2ids(body){
  return body.split("http")
    .filter( l => l.match(/text-code-xr-engine\/issues\/\d+/) ) 
    .map( l => l.replace(/.*\issues\/(\d+)\D*/, (str,id) => id ) ).filter( i => i.length > 0)
}

Note that interesting these very comments were becoming edge cases.

example for all issues with all their comments ```javascript fetch("https://git.benetou.fr/api/v1/repos/utopiah/text-code-xr-engine/issues") .then( res => res.json() ) .then( res => { var nodes = {} res.map( i => { if (body2ids(i.body).length > 0) nodes[i.id]=body2ids(i.body) fetch("https://git.benetou.fr/api/v1/repos/utopiah/text-code-xr-engine/issues/"+i.id+"/comments") .then( res => res.json() ) .then( c => { if (c.length ) c.map( comm => { if (body2ids( comm.body ).length>0) if (nodes[i.id]) nodes[i.id] = [...new Set( nodes[i.id].concat( body2ids( comm.body )) )] else nodes[i.id] = body2ids( comm.body ) } ) }) } ) console.log(nodes) } ) function body2ids(body){ return body.split("http") .filter( l => l.match(/text-code-xr-engine\/issues\/\d+/) ) .map( l => l.replace(/.*\issues\/(\d+)\D*/, (str,id) => id ) ).filter( i => i.length > 0) } ``` Note that interesting these very comments were becoming edge cases.
Poster
Owner

Consider also the more global perspective, e.g per branch

fetch("https://git.benetou.fr/api/v1/repos/utopiah/text-code-xr-engine/branches")
.then( r => r.json() )
.then(r => 
	r.sort( (a,b) => a.commit.timestamp < b.commit.timestamp)
    	.map( i => console.log(i.name, i.commit.timestamp, i.commit.message))
        // or addNewNote()
    )
Consider also the more global perspective, e.g per branch ```javascript fetch("https://git.benetou.fr/api/v1/repos/utopiah/text-code-xr-engine/branches") .then( r => r.json() ) .then(r => r.sort( (a,b) => a.commit.timestamp < b.commit.timestamp) .map( i => console.log(i.name, i.commit.timestamp, i.commit.message)) // or addNewNote() ) ```
Poster
Owner

Consider the graph branch https://git.benetou.fr/utopiah/text-code-xr-engine/src/branch/graph in order to show the result.

Consider the graph branch https://git.benetou.fr/utopiah/text-code-xr-engine/src/branch/graph in order to show the result.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: utopiah/text-code-xr-engine#46
Loading…
There is no content yet.