Wiki source code of Recommended Status

Last modified by Vincent Massol on 2020/02/21 14:32

Show last authors
1 Helps decide if a Recommended Extension should be unrecommended or not, based on [[its activity>>ExtensionCode.RecommendedExtensions.RecommendedDefinition.WebHome]].
2
3 Pass "confirm=1" in the URL to execute.
4
5 {{groovy}}
6 import groovy.json.*
7 import org.apache.commons.lang3.StringUtils
8
9 def check(projectName)
10 {
11 // Any bug updated during the past 365 days?
12 def jql = "project = '${projectName}' AND updated >= -365d AND type = Bug AND priority > Minor"
13 def url = "http://jira.xwiki.org/rest/api/2/search?jql=${java.net.URLEncoder.encode(jql)}".toURL().text
14 def root = new JsonSlurper().parseText(url)
15 def bugUpdates = root.issues.size
16 if (bugUpdates > 0) {
17 // Since there were bugs updated (ie we consider that some users have reported something), we need to check if any developer activity has been performed.
18 jql = "project = '${projectName}' AND updated >= -365d AND resolution = Fixed"
19 url = "http://jira.xwiki.org/rest/api/2/search?jql=${java.net.URLEncoder.encode(jql)}".toURL().text
20 root = new JsonSlurper().parseText(url)
21 def devUpdates = root.issues.size
22 if (devUpdates == 0) {
23 // Bad, the extension is a candidate for being unrecommended
24 return "Should unrecommend (bug updates = ${bugUpdates}, dev updates = 0)"
25 } else {
26 return "Activity happened in the Extension, it should continue being recommended (bug updates = ${bugUpdates}, dev updates = ${devUpdates})"
27 }
28 } else {
29 return "Nothing asked by user. Extension should continue being recommended"
30 }
31 }
32
33 if (request.confirm == '1') {
34 def xwql = "select doc.fullName, extension.issueManagementURL from Document doc, doc.object(ExtensionCode.ExtensionClass) as extension"
35 def query
36 if (request.scope == 'all') {
37 query = services.query.xwql(xwql)
38 } else if (request.scope) {
39 query = services.query.xwql("${xwql} where doc.fullName = :extensionName").bindValue('extensionName', request.scope)
40 } else {
41 query = services.query.xwql("${xwql} where extension.recommended = 1")
42 }
43 println "|=Extension|= JIRA Project|=Recommended Status"
44 query.execute().each() {
45 def jiraId = StringUtils.substringAfterLast(it[1], '/')
46 if (jiraId) {
47 println "|[[${it[0]}]]|[[${it[1]}>>${it[1]}]]|${check(jiraId)}"
48 } else {
49 println "|[[${it[0]}]]|[[${it[1]}>>${it[1]}]]|Missing issue mgmt URL!"
50 }
51 }
52 }
53 {{/groovy}}

Get Connected