A new feature has been released in Mozilla bug tracker: the mentor bug field. Sometimes working on a bug can be pretty intimidating, specifically for new contributors. So to help, Mozilla had created a whiteboard keyboard for associating a bug to a mentor: [mentor=kdubost]
. A contributor would know who to ask if s/he wanted to take ownership and work on it.
It also helped with projects like BugsAHoy!. For example if you have interest in Developer Tools, it becomes easier to find the bugs where they will be help.
So in Web Compatibility we have a few mentors and a few bugs too for Site Outreach and Site Analysis. We haven't had a lot of success yet with them, but it's more by our own lack of publicity about them. This will have to be fixed. I wanted to know if we had a lot of mentored bugs. Using httpie, I first collected the list of bugs with a non empty mentor field.
http -b GET "https://bugzilla.mozilla.org/rest/bug?product=Tech%20Evangelism&bug_mentor_type=substring&bug_mentor=@" > /tmp/mentor.json
Then because I'm tortured enough to like the command line, I went onto processing the result with python.
cat /tmp/mentor.json | python -c "import itertools, json, sys; data=json.loads(sys.stdin.read()); datajson = data['bugs']; mentor_list = [bug['mentors_detail'][0]['real_name'] for bug in datajson]; print [(a,len(list(b))) for a,b in itertools.groupby(sorted(mentor_list))]"
The result was:
[(u'Adam Stevenson', 60),
(u'Hallvord R. M. Steen', 84),
(u'Karl Dubost :karlcow', 36),
(u'Mike Taylor [:miketaylr]', 6)]
Ok let's see what's hidden in there. First the real bash part
cat /tmp/mentor.json | python -c "#piece of python code"
The rest is python code
import itertools
import json
import sys
# We read the data stream input from the command line and parse it as JSON
data=json.loads(sys.stdin.read())
# The first group is just the keyword bugs
datajson = data['bugs']
# Using a comprehension list we extract the data from the json file
# You might note the positional argument in there, list of lists :/
mentor_list = [bug['mentors_detail'][0]['real_name'] for bug in datajson];
# Then we use itertools to group the common sorted elements of the list
# and to count each item. A basically "| sort | uniq -c" in bash.
print [(a,len(list(b))) for a,b in itertools.groupby(sorted(mentor_list))]
So to come back to the result:
[(u'Adam Stevenson', 60),
(u'Hallvord R. M. Steen', 84),
(u'Karl Dubost :karlcow', 36),
(u'Mike Taylor [:miketaylr]', 6)]
We can certainly improve, because we have a lot more bugs than that, which are about just contacting companies: 286.
Otsukare.