Document toolboxDocument toolbox

See Details for Inactive Structures

The following script will list structure names that weren't accessed for 6 months, its owner, and last opened value.

import com.onresolve.scriptrunner.runner.customisers.WithPlugin import java.time.Duration import com.onresolve.scriptrunner.runner.ScriptRunnerImpl import com.almworks.jira.structure.api.StructureComponents import com.almworks.jira.structure.api.permissions.PermissionLevel @Grab(group = 'com.almworks.jira.structure', module = 'structure-api', version = '*') @WithPlugin('com.almworks.jira.structure') def sc = ScriptRunnerImpl.getPluginComponent(StructureComponents) def sm = sc.getStructureManager() def sps = sc.getStructurePropertyService() def currentTime = System.currentTimeMillis() def structures = sm.getAllStructures(PermissionLevel.VIEW) //structures not accessed for 6 months def sixMonthPlusOldStructures = structures.findAll { structure -> def lastPolledMillis = sps.getLong(structure.id, "lastPolledMillis", 0) return lastPolledMillis > 0 && Duration.ofMillis(currentTime - lastPolledMillis).toDays() > 180 //6 months ~ 180 days }.collect{ [it.name, Duration.ofMillis(currentTime - sps.getLong(it.id, "lastPolledMillis", 0)).toDays(), it.owner] } //structures that were created but never opened def createdButNeverOpened = structures.findAll { structure -> def lastPolledMillis = sps.getLong(structure.id, "lastPolledMillis", 0) return lastPolledMillis == 0 }.collect{ [it.name, it.owner] } return [ sixMonthPlusOldStructures: sixMonthPlusOldStructures, createdButNeverOpened: createdButNeverOpened ]