community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject svn commit: r1663885 - in /comdev/reporter.apache.org/site: getjson.py render.js
Date Wed, 04 Mar 2015 08:24:39 GMT
Author: humbedooh
Date: Wed Mar  4 08:24:38 2015
New Revision: 1663885

URL: http://svn.apache.org/r1663885
Log:
be smarter about how we fetch JIRA keys, using categories to determine which keys match which
project

Modified:
    comdev/reporter.apache.org/site/getjson.py
    comdev/reporter.apache.org/site/render.js

Modified: comdev/reporter.apache.org/site/getjson.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/site/getjson.py?rev=1663885&r1=1663884&r2=1663885&view=diff
==============================================================================
--- comdev/reporter.apache.org/site/getjson.py (original)
+++ comdev/reporter.apache.org/site/getjson.py Wed Mar  4 08:24:38 2015
@@ -3,11 +3,8 @@ import os, sys, re, json, subprocess, ur
 import base64, urllib2
 
 jmap = {
-    'trafficserver': 'TS',
-    'couchdb': 'COUCHDB',
-    'cloudstack': 'CLOUDSTACK',
-    'comdev': 'COMDEV',
-    'cordova': 'CB'
+    'trafficserver': ['TS'],
+    'cordova': ['CB']
 }
 
 pmap = {
@@ -18,7 +15,7 @@ jirapass = ""
 with open("/var/www/reporter.apache.org/data/jirapass.txt", "r") as f:
     jirapass = f.read().strip()
     f.close()
-    
+
 def getPMCs(uid):
     groups = []
     ldapdata = subprocess.check_output(['ldapsearch', '-x', '-LLL', '(|(memberUid=%s)(member=uid=%s,ou=people,dc=apache,dc=org))'
% (uid, uid), 'cn'])
@@ -26,7 +23,7 @@ def getPMCs(uid):
     for match in re.finditer(r"dn: cn=([a-zA-Z0-9]+),ou=pmc,ou=committees,ou=groups,dc=apache,dc=org",
ldapdata):
         group = match.group(1)
         if group != "incubator":
-            
+
             groups.append(group)
     return groups
 
@@ -41,13 +38,51 @@ def isMember(uid):
         return True
     return False
 
+def getJIRAProjects(project):
+    project = project.replace("Apache ", "").strip().lower()
+    refresh = True
+    x = {}
+    jiras = []
+    try:
+        mtime = 0
+        try:
+            st=os.stat("/var/www/reporter.apache.org/data/JIRA/projects.json")
+            mtime=st.st_mtime
+        except:
+            pass
+        if mtime >= (time.time() - 86400):
+            refresh = False
+            with open("/var/www/reporter.apache.org/data/JIRA/projects.json", "r") as f:
+                x = json.loads(f.read())
+                f.close()
+        else:
+            base64string = base64.encodestring('%s:%s' % ('githubbot', jirapass))[:-1]
+    
+            try:
+                req = req = urllib2.Request("https://issues.apache.org/jira/rest/api/2/project.json")
+                req.add_header("Authorization", "Basic %s" % base64string)
+                x = json.loads(urllib2.urlopen(req).read())
+                with open("/var/www/reporter.apache.org/data/JIRA/projects.json", "w") as
f:
+                    f.write(json.dumps(x))
+                    f.close()
+            except:
+                pass
+    except:
+        pass
+    
+    for entry in x:
+        if entry['name'].replace("Apache ", "").strip().lower() == project:
+            jiras.append(entry['key'])
+        elif 'projectCategory' in entry and entry['projectCategory']['name'].replace("Apache
", "").strip().lower() == project:
+            jiras.append(entry['key'])
+    return jiras
 
 def getJIRAS(project):
     refresh = True
     try:
-        st=os.stat("/var/www/reporter.apache.org/data/JIRA/%s.json" % project)    
+        st=os.stat("/var/www/reporter.apache.org/data/JIRA/%s.json" % project)
         mtime=st.st_mtime
-        if mtime >= (time.time() - 14400):
+        if mtime >= (time.time() - 86400):
             refresh = False
             with open("/var/www/reporter.apache.org/data/JIRA/%s.json" % project, "r") as
f:
                 x = json.loads(f.read())
@@ -55,10 +90,10 @@ def getJIRAS(project):
                 return x[0], x[1], x[2]
     except:
         pass
-    
+
     if refresh:
         base64string = base64.encodestring('%s:%s' % ('githubbot', jirapass))[:-1]
-        
+
         try:
             req = req = urllib2.Request("""https://issues.apache.org/jira/rest/api/2/search?jql=project%20=%20"""
+ project + """%20AND%20created%20%3E=%20-91d""")
             req.add_header("Authorization", "Basic %s" % base64string)
@@ -93,7 +128,7 @@ def getProjectData(project):
                 for xproject in c:
                     if xproject == x['name']:
                         x['chair'] = c[xproject]
-            
+
         return x;
     except:
         x = {}
@@ -103,15 +138,15 @@ def getProjectData(project):
             for xproject in p:
                 if xproject == project:
                     x['name'] = p[project]['name']
-                    
+
         with open("/var/www/projects.apache.org/site/json/foundation/chairs.json", "r") as
f:
-                c = json.loads(f.read())
-                f.close()
-                for xproject in c:
-                    if 'name' in x and xproject == x['name']:
-                        x['chair'] = c[xproject]
+            c = json.loads(f.read())
+            f.close()
+            for xproject in c:
+                if 'name' in x and xproject == x['name']:
+                    x['chair'] = c[xproject]
         return x
-    
+
 def getReleaseData(project):
     try:
         with open("/var/www/reporter.apache.org/data/releases/%s.json" % project, "r") as
f:
@@ -120,7 +155,7 @@ def getReleaseData(project):
         return x;
     except:
         return {}
-    
+
 
 
 pchanges = {}
@@ -133,8 +168,8 @@ with open("/var/www/reporter.apache.org/
 with open("/var/www/reporter.apache.org/data/projects.json", "r") as f:
     cchanges = json.loads(f.read())
     f.close()
-    
-    
+
+
 user = os.environ['HTTP_X_AUTHENTICATED_USER'] if 'HTTP_X_AUTHENTICATED_USER' in os.environ
else ""
 m = re.match(r"^([-a-zA-Z0-9_.]+)$", user)
 groups = []
@@ -145,7 +180,7 @@ if m:
     groups = getPMCs(uid)
     include = os.environ['QUERY_STRING'] if 'QUERY_STRING' in os.environ else None
     if include and isMember(uid) and not include in groups and len(include) > 1:
-        groups.append(include)    
+        groups.append(include)
     mlstats = {}
     with open("/var/www/reporter.apache.org/data/mailinglists.json", "r") as f:
         ml = json.loads(f.read())
@@ -171,19 +206,31 @@ if m:
     jdata = {}
     ddata = {}
     rdata = {}
+    jiras = []
     for group in groups:
         jdata[group] = [0,0, None]
         ddata[group] = getProjectData(group)
         rdata[group] = getReleaseData(group)
         jiraname = group.upper()
         if group in jmap:
-            jiraname = jmap[group]
-        if jiraname:
+            for jiraname in jmap[group]:
+                x,y, p = getJIRAS(jiraname)
+                jdata[group][0] += x
+                jdata[group][1] += y
+                jdata[group][2] = p
+        elif group in ddata and 'name' in ddata[group]:
+            jiras = getJIRAProjects(ddata[group]['name'])
+            for jiraname in jiras:
+                x,y, p= getJIRAS(jiraname)
+                jdata[group][0] += x
+                jdata[group][1] += y
+                jdata[group][2] = p
+        elif jiraname:
             x,y, p= getJIRAS(jiraname)
             jdata[group][0] += x
             jdata[group][1] += y
             jdata[group][2] = p
-            
+
         cdata[group] = cdata[group] if group in cdata else {'pmc': {}, 'committer': {}}
         for pmc in pchanges:
             if pmc == group:
@@ -202,7 +249,8 @@ if m:
         'jira': jdata,
         'changes': cdata,
         'pdata': ddata,
-        'releases': rdata
+        'releases': rdata,
+        'keys': jiras
     }
     dump = json.dumps(output)
     print ("Content-Type: application/json\r\nContent-Length: %u\r\n\r\n" % (len(dump)+1))
@@ -210,4 +258,3 @@ if m:
 else:
     print ("Content-Type: text/html\r\n\r\n")
     print("Unknown or invalid user id presented")
-        

Modified: comdev/reporter.apache.org/site/render.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/site/render.js?rev=1663885&r1=1663884&r2=1663885&view=diff
==============================================================================
--- comdev/reporter.apache.org/site/render.js (original)
+++ comdev/reporter.apache.org/site/render.js Wed Mar  4 08:24:38 2015
@@ -503,6 +503,9 @@ function renderJIRA(pmc, project) {
     addLine(pmc)
     obj.innerHTML += jsdata.jira[pmc][0] + " JIRA tickets created in the last 3 months<br/>";
     obj.innerHTML += jsdata.jira[pmc][1] + " JIRA tickets closed/resolved in the last 3 months<br/>";
+	if (jsdata.keys) {
+		obj.innerHTML += "Keys used: <kbd>" + jsdata.keys.join(", ") + "</kbd>"
+	}
     
 }
 



Mime
View raw message