Merge lp:~powersj/merge-o-matic/enable-team-stats into lp:merge-o-matic

Proposed by Joshua Powers
Status: Merged
Merged at revision: 297
Proposed branch: lp:~powersj/merge-o-matic/enable-team-stats
Merge into: lp:merge-o-matic
Diff against target: 94 lines (+29/-2)
3 files modified
cron.daily (+1/-0)
momlib.py (+14/-0)
stats.py (+14/-2)
To merge this branch: bzr merge lp:~powersj/merge-o-matic/enable-team-stats
Reviewer Review Type Date Requested Status
Brian Murray Approve
Review via email: mp+326959@code.launchpad.net

Description of the change

The stats produced from merge-o-matic are great, however getting details at the team level are not possible. This enables statistics at the team level for any team that wants.

To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) wrote :

I've merged this and set it up the server, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cron.daily'
2--- cron.daily 2017-06-09 00:36:25 +0000
3+++ cron.daily 2017-07-06 19:15:08 +0000
4@@ -82,6 +82,7 @@
5
6 # Produce pretty reports
7 ./stats.py $QUIET
8+./stats.py $QUIET -t ubuntu-server
9 ./stats-graphs.py $QUIET
10 ./merge-status.py $QUIET
11 ./manual-status.py $QUIET
12
13=== modified file 'momlib.py'
14--- momlib.py 2017-04-21 12:24:01 +0000
15+++ momlib.py 2017-07-06 19:15:08 +0000
16@@ -226,6 +226,20 @@
17 else:
18 return ""
19
20+def get_team_packages(team):
21+ """Return list of packages owned by a team."""
22+ if not team:
23+ return []
24+
25+ mapping_file = "%s/code/package-team-mapping.json" % ROOT
26+ if os.path.exists(mapping_file):
27+ with open(mapping_file) as ptm_file:
28+ for fteam, packages in json.load(ptm_file).items():
29+ if team == fteam:
30+ return packages
31+
32+ return []
33+
34 # --------------------------------------------------------------------------- #
35 # Location functions
36 # --------------------------------------------------------------------------- #
37
38=== modified file 'stats.py'
39--- stats.py 2016-11-13 03:15:26 +0000
40+++ stats.py 2017-07-06 19:15:08 +0000
41@@ -28,6 +28,7 @@
42 get_base,
43 get_same_source,
44 get_sources,
45+ get_team_packages,
46 OUR_DIST,
47 OUR_DISTRO,
48 read_blacklist,
49@@ -59,6 +60,8 @@
50 parser.add_option("-c", "--component", type="string", metavar="COMPONENT",
51 action="append",
52 help="Process only these destination components")
53+ parser.add_option("-t", "--team", type="string", metavar="TEAM",
54+ help="Process only packages owned by this team")
55
56 def main(options, args):
57 src_distro = options.source_distro
58@@ -67,6 +70,8 @@
59 our_distro = options.dest_distro
60 our_dist = options.dest_suite
61
62+ team = options.team
63+ team_package_list = get_team_packages(team)
64 blacklist = read_blacklist()
65
66 # For each package in the destination distribution, locate the latest in
67@@ -91,6 +96,9 @@
68 continue
69
70 package = our_source["Package"]
71+ if team_package_list and package not in team_package_list:
72+ continue
73+
74 our_version = Version(our_source["Version"])
75 logging.debug("%s: %s is %s", package, our_distro, our_version)
76
77@@ -131,11 +139,15 @@
78 logging.debug("%s: modified", package)
79 stats["modified"] += 1
80
81- write_stats(our_component, stats)
82+ write_stats(our_component, stats, team)
83
84-def write_stats(component, stats):
85+def write_stats(component, stats, team):
86 """Write out the collected stats."""
87 stats_file = "%s/stats.txt" % ROOT
88+
89+ if team:
90+ stats_file = "%s/stats-%s.txt" % (ROOT, team)
91+
92 with open(stats_file, "a") as stf:
93 stamp = time.strftime("%Y-%m-%d %H:%M", time.gmtime())
94 text = " ".join("%s=%d" % (k, v) for k,v in stats.items())

Subscribers

People subscribed via source and target branches

to status/vote changes: