Visualize Your Unresolved Issues with VisualScript Studio

Overview

Visualizing your unresolved issues sounds like some sort of new age meditation technique, but this article will mostly focus on your work in Jira. You'll have to figure out any mom issues you may have independently. The idea behind creating this script was to take what you may be used to seeing when you login to Jira every day - a list of the most recent issues assigned to you - and make that a visual.

Jira unresolved issues visualization

For this script, there's no real user interface. The script will use your identity (as the current user) to run its query, and will choose issues from all project that are assigned to you and have status of "open", "re-open" or "in progress".

How I Implemented It

Obtaining the Data

The first step is to get data from Jira using VSCallFunctionForJiraQuery and the Jira REST API I pass it the parameter "assignee = currentUser()" and parameters to filter on the status, which can be "open", "reopened" or "in progress" (basically, not "to do" or "done" in a normally-configured Jira). Finally, I specify that the results should be sorted by the created date.

// Issue the query in the params. Calls the handler with the issues list VSCallFunctionForJiraQuery(gSDJSLocalHost, "assignee = currentUser() AND (status = Open OR status = Reopened OR status = \"In Progress\") ORDER BY created ASC", handler);

Building the Model

This is such a simple script that Jira basically builds the model for you. The list of issues returned by the query contains all the information needed to build VisualScript.

Building the VisualScript

To build VisualScript markup from the issues list, I first set up the main document and create a label on the main (or "root") shape. Then I want to add a connector to the main shape that I can use to visually connect all the issue shapes. I then loop through the issues, adding a shape for each to the main shape's connector. I use a table inside the shape to separate the name/key of the issue and a brief summary. I also set a "text hyperlink" on the key of the shape so that the user can click an issue to explore it further.

// Handle the response function handler(issues) { var i, len, issueShape, issueShapeTable, mainShape, connector, vs = {}; // Set up the document vs = new VS.Document(); vs.SetTemplate("Mindmap"); // Set up the main/root shape mainShape = vs.GetTheShape() .SetLabel("Unresolved Issues Assigned to Me") .SetFillColor("#D5D5D5") .SetTextColor("#000000"); connector = mainShape.AddShapeConnector(); // Add a shape for each issue len = issues.length; for (i = 0; i < len; i++) { issueShape = connector.AddShape() .SetFillColor("#ACE2FC"); issueShapeTable = issueShape.AddTable(2, 1); issueShapeTable.AddCell(1, 1) .SetLabel(issues[i].key) .SetTextHyperlink(localhost + "/browse/" + issues[i].key); issueShapeTable.AddCell(2, 1) .SetLabel(issues[i].fields.summary); }

After creating the VS.Document and getting the "root shape", I iterate through each property in the model's issueDirections. For each "direction", I create a shape to represent the direction. I attach a shapeConnector to it and then add a shape to that connector for each issue in the direction's issue list. I chose to represent the issue in a table inside the shape for formatting purposes. The top row of the table contains the key and the bottom row contains the summary.

Rendering the VisualScript

The last step is to render the VisualSCript markup as a visual using a callback function. To make the code easier to understand, I highlighted the part used for querying the data in green, the part for building the model in orange, and the part that creates VisualScript from the data in blue.

// Render the VisualScript
callback(vs.toJSON());

More Information

This is just one example of the useful visuals that can be produced using VisualScript and VisualScript Studio with a minimum of development effort.

The full source for this script can be seen here. To make the code easier to understand, I highlighted the part used for querying the data in green, the part for building the model in orange, and the part that creates VisualScript from the data in blue.

function VisualScript(localhost, params, callback) { // Display the unresolved issues that are assigned to the current user. // Issue the query in the params. Calls the handler with the issues list VSCallFunctionForJiraQuery(gSDJSLocalHost, "assignee = currentUser() AND (status = Open OR status = Reopened OR status = \"In Progress\") ORDER BY created ASC", handler);
// Handle the response function handler(issues) { var i, len, issueShape, issueShapeTable, issueShapeTableCell, mainShape, connector, vs = {}; vs = new VS.Document(); vs.SetTemplate("Mindmap"); mainShape = vs.GetTheShape() .SetLabel("Unresolved Issues Assigned to Me") .SetFillColor("#D5D5D5") .SetTextColor("#000000"); connector = mainShape.AddShapeConnector(); len = issues.length; for (i = 0; i < len; i++) { issueShape = connector.AddShape() .SetFillColor("#ACE2FC"); issueShapeTable = issueShape.AddTable(2, 1); issueShapeTable.AddCell(1, 1) .SetLabel(issues[i].key) .SetTextHyperlink(localhost + "/browse/" + issues[i].key); issueShapeTable.AddCell(2, 1) .SetLabel(issues[i].fields.summary); } // Render the VisualScript callback(vs.toJSON()); } }