Change ActiveWGMembers output to CSV, fix ops
The previous variable-space separated output that get_active_wg_members output was great for humans. Machines, not so much. Accordingly, our developers asked for it to be something like csv instead. This patch changes the default output to be CSV. In order to retain human-led debugging ability, the --human option was added. Since we now have options, all of the parameters previously hard-coded were made into options. No threshold values were changed. New options: -h, --help show this help message and exit --human If set, output results in human-readable format -d DATADIR, --datadir=DATADIR Where meeting data lives -t DAYS, --days=DAYS Validity of attendance in days -n NUMMEETINGS, --nummeetings=NUMMEETINGS Required number of meetings -l LINESSAID, --linessaid=LINESSAID Required number of line said also, add a .gitreview file for good measure Change-Id: I1e7ca4760c069b57a3b4ad5a1bd62f5465e5e856
This commit is contained in:
parent
d9535c1dbc
commit
34f4c5304c
4
.gitreview
Normal file
4
.gitreview
Normal file
@ -0,0 +1,4 @@
|
||||
[gerrit]
|
||||
host=review.openstack.org
|
||||
port=29418
|
||||
project=openstack/uc-recognition.git
|
@ -18,6 +18,7 @@
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
import operator
|
||||
import optparse
|
||||
import os
|
||||
|
||||
meeting_mappings = {
|
||||
@ -122,7 +123,7 @@ def print_meet_stats(meeting_data):
|
||||
user[1]["lines_said"])
|
||||
|
||||
|
||||
def print_eligible_usernames(meeting_data, num_meetings=1, lines_said=1):
|
||||
def print_eligible_usernames(meeting_data, num_meetings=1, lines_said=1, human=False):
|
||||
user_aggregate = {}
|
||||
for meeting_name in meeting_data.keys():
|
||||
for user_tuple in meeting_data[meeting_name].items():
|
||||
@ -131,22 +132,47 @@ def print_eligible_usernames(meeting_data, num_meetings=1, lines_said=1):
|
||||
else:
|
||||
user_aggregate[user_tuple[0]]["lines_said"] += user_tuple[1]["lines_said"]
|
||||
user_aggregate[user_tuple[0]]["attendance_count"] += user_tuple[1]["attendance_count"]
|
||||
|
||||
print "\n OVERALL STATS \n=====================================\n"
|
||||
if human:
|
||||
print "\n OVERALL STATS \n=====================================\n"
|
||||
sorted_users = sorted(user_aggregate.items(), reverse=True,
|
||||
key=operator.itemgetter(1))
|
||||
for user in sorted_users:
|
||||
if user[1]["attendance_count"] >= num_meetings or user[1]["lines_said"] >= lines_said:
|
||||
print "{: <20} {: <20} {: <20}".format(user[0],
|
||||
user[1]["attendance_count"],
|
||||
user[1]["lines_said"])
|
||||
if human:
|
||||
print "{: <20} {: <20} {: <20}".format(user[0],
|
||||
user[1]["attendance_count"],
|
||||
user[1]["lines_said"])
|
||||
else:
|
||||
print "{},{},{}".format(user[0],
|
||||
user[1]["attendance_count"],
|
||||
user[1]["lines_said"])
|
||||
|
||||
|
||||
def main():
|
||||
meeting_data = get_recent_meets("./eavesdrop.openstack.org/meetings", 183)
|
||||
optparser = optparse.OptionParser()
|
||||
optparser.add_option(
|
||||
'--human', help='If set, output results in human-readable format',
|
||||
default=False, action="store_true")
|
||||
optparser.add_option(
|
||||
'-d', '--datadir', help='Where meeting data lives',
|
||||
default='./eavesdrop.openstack.org/meetings')
|
||||
optparser.add_option(
|
||||
'-t', '--days', help='Validity of attendance in days',
|
||||
type="int", default=183)
|
||||
optparser.add_option(
|
||||
'-n', '--nummeetings', help='Required number of meetings',
|
||||
type="int", default=2)
|
||||
optparser.add_option(
|
||||
'-l', '--linessaid', help='Required number of line said',
|
||||
type="int", default=10)
|
||||
options, args = optparser.parse_args()
|
||||
|
||||
meeting_data = get_recent_meets(options.datadir, options.days)
|
||||
meeting_aggregate = get_meeting_aggregates(meeting_data)
|
||||
print_meet_stats(meeting_aggregate)
|
||||
print_eligible_usernames(meeting_aggregate, 2, 10)
|
||||
if options.human:
|
||||
print_meet_stats(meeting_aggregate)
|
||||
print_eligible_usernames(meeting_aggregate, options.nummeetings,
|
||||
options.linessaid, options.human)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user