def getLongestThreads(startdate, enddate, identities_db, npeople): # This function builds a coherent data structure according # to other simila structures. The Class Threads only returns # the head of the threads (the first message) and the message_id # of each of its children. main_topics = Threads(startdate, enddate, identities_db) longest_threads = main_topics.topLongestThread(npeople) l_threads = {} l_threads['message_id'] = [] l_threads['length'] = [] l_threads['subject'] = [] l_threads['date'] = [] l_threads['initiator_name'] = [] l_threads['initiator_id'] = [] l_threads['url'] = [] for email in longest_threads: l_threads['message_id'].append(email.message_id) l_threads['length'].append(main_topics.lenThread(email.message_id)) l_threads['subject'].append(email.subject) if not isinstance(email.date, list): #not expected result: an empty list. l_threads['date'].append(email.date.strftime("%Y-%m-%d")) l_threads['initiator_name'].append(email.initiator_name) l_threads['initiator_id'].append(email.initiator_id) l_threads['url'].append(email.url) return l_threads
def mls_report(dbcon, filters): # Per release MLS information emails = mls.EmailsSent(dbcon, filters) createJSON(emails.get_agg(), "./release/mls_emailssent.json") senders = mls.EmailsSenders(dbcon, filters) createJSON(senders.get_agg(), "./release/mls_emailssenders.json") senders_init = mls.SendersInit(dbcon, filters) createJSON(senders_init.get_agg(), "./release/mls_sendersinit.json") dataset = {} dataset["sent"] = emails.get_agg()["sent"] dataset["senders"] = senders.get_agg()["senders"] dataset["senders_init"] = senders_init.get_agg()["senders_init"] from vizgrimoire.analysis.threads import Threads SetDBChannel(dbcon.user, dbcon.password, dbcon.database) threads = Threads(filters.startdate, filters.enddate, dbcon.identities_db) top_longest_threads = threads.topLongestThread(10) top_longest_threads = serialize_threads(top_longest_threads, False, threads) createJSON(top_longest_threads, "./release/mls_top_longest_threads.json") createCSV(top_longest_threads, "./release/mls_top_longest_threads.csv") #top_crowded_threads = threads.topCrowdedThread(10) #top_crowded_threads = serialize_threads(top_crowded_threads, True, threads) #createJSON(top_crowded_threads, "./release/mls_top_crowded_threads.json") #createCSV(top_crowded_threads, "./release/mls_top_crowded_threads.csv") return dataset
def mls_report(dbcon, filters, output_dir): dataset = {} emails = mls.EmailsSent(dbcon, filters) dataset["mls_sent"] = emails.get_agg()["sent"] senders = mls.EmailsSenders(dbcon, filters) dataset["mls_senders"] = senders.get_agg()["senders"] senders_init = mls.SendersInit(dbcon, filters) dataset["mls_senders_init"] = senders_init.get_agg()["senders_init"] from vizgrimoire.analysis.threads import Threads SetDBChannel(dbcon.user, dbcon.password, dbcon.database) threads = Threads(filters.startdate, filters.enddate, dbcon.identities_db) top_longest_threads = threads.topLongestThread(10) top_longest_threads = serialize_threads(top_longest_threads, False, threads) createJSON(top_longest_threads, output_dir + "/mls_top_longest_threads.json") createCSV(top_longest_threads, output_dir + "/mls_top_longest_threads.csv") top_crowded_threads = threads.topCrowdedThread(10) top_crowded_threads = serialize_threads(top_crowded_threads, True, threads) createJSON(top_crowded_threads, output_dir + "/mls_top_crowded_threads.json") createCSV(top_crowded_threads, output_dir + "/mls_top_crowded_threads.csv") return dataset
def mls_report(dbcon, filters): # Per release MLS information emails = mls.EmailsSent(dbcon, filters) createJSON(emails.get_agg(), "./release/mls_emailssent.json") senders = mls.EmailsSenders(dbcon, filters) createJSON(senders.get_agg(), "./release/mls_emailssenders.json") senders_init = mls.SendersInit(dbcon, filters) createJSON(senders_init.get_agg(), "./release/mls_sendersinit.json") dataset = {} dataset["sent"] = emails.get_agg()["sent"] dataset["senders"] = senders.get_agg()["senders"] dataset["senders_init"] = senders_init.get_agg()["senders_init"] from vizgrimoire.analysis.threads import Threads SetDBChannel(dbcon.user, dbcon.password, dbcon.database) threads = Threads(filters.startdate, filters.enddate, dbcon.identities_db) top_longest_threads = threads.topLongestThread(10) top_longest_threads = serialize_threads(top_longest_threads, False, threads) createJSON(top_longest_threads, "./release/mls_top_longest_threads.json") createCSV(top_longest_threads, "./release/mls_top_longest_threads.csv") top_crowded_threads = threads.topCrowdedThread(10) top_crowded_threads = serialize_threads(top_crowded_threads, True, threads) createJSON(top_crowded_threads, "./release/mls_top_crowded_threads.json") createCSV(top_crowded_threads, "./release/mls_top_crowded_threads.csv") return dataset
def mls_report(dbcon, filters): emails_sent = mls.EmailsSent(dbcon, filters) createJSON(emails_sent.get_agg(), "./release/mls_emailsent.json") print(emails_sent.get_agg()) emails_senders = mls.EmailsSenders(dbcon, filters) createJSON(emails_senders.get_agg(), "./release/mls_emailsenders.json") print(emails_senders.get_agg()) top = {} from vizgrimoire.MLS import MLS msenders = mls.EmailsSenders(dbcon, filters) top["EmailSenders"] = msenders.get_list(filters, 90) createJSON(top, "./release/mls_top_email_senders.json") createCSV(top["EmailSenders"], "./release/mls_top_email_senders.csv", ['id']) from vizgrimoire.analysis.threads import Threads SetDBChannel(dbcon.user, dbcon.password, dbcon.database) top_threads = {} top_threads['threads'] = MLS.getLongestThreads(filters.startdate, filters.enddate, dbcon.identities_db, str(filters.npeople)) createJSON(top_threads, "./release/mls_top_longest_threads.json") createCSV(top_threads["threads"], "./release/mls_top_longest_threads.csv", ['initiator_id', 'message_id']) main_topics = Threads(filters.startdate, filters.enddate, dbcon.identities_db) top_crowded = main_topics.topCrowdedThread(int(filters.npeople)) l_threads = {} l_threads['message_id'] = [] l_threads['people'] = [] l_threads['subject'] = [] l_threads['date'] = [] l_threads['initiator_name'] = [] l_threads['initiator_id'] = [] l_threads['url'] = [] for email_people in top_crowded: email = email_people[0] l_threads['message_id'].append(email.message_id) l_threads['people'].append(email_people[1]) l_threads['subject'].append(email.subject) l_threads['date'].append(email.date.strftime("%Y-%m-%d")) l_threads['initiator_name'].append(email.initiator_name) l_threads['initiator_id'].append(email.initiator_id) l_threads['url'].append(email.url) createJSON(l_threads, "./release/mls_top_crowded_threads.json") createCSV(l_threads, "./release/mls_top_crowded_threads.csv", ['initiator_id', 'message_id'])
def mls_report(dbcon, filters): emails_sent = mls.EmailsSent(dbcon, filters) createJSON(emails_sent.get_agg(), "./release/mls_emailsent.json") print(emails_sent.get_agg()) emails_senders = mls.EmailsSenders(dbcon, filters) createJSON(emails_senders.get_agg(), "./release/mls_emailsenders.json") print(emails_senders.get_agg()) top = {} from vizgrimoire.MLS import MLS msenders = mls.EmailsSenders(dbcon, filters) top["EmailSenders"] = msenders.get_list(filters, 90) createJSON(top, "./release/mls_top_email_senders.json") createCSV(top["EmailSenders"], "./release/mls_top_email_senders.csv", ['id']) from vizgrimoire.analysis.threads import Threads SetDBChannel(dbcon.user, dbcon.password, dbcon.database) top_threads = {} top_threads['threads'] = MLS.getLongestThreads(filters.startdate, filters.enddate, dbcon.identities_db, str(filters.npeople)) createJSON(top_threads, "./release/mls_top_longest_threads.json") createCSV(top_threads["threads"], "./release/mls_top_longest_threads.csv", ['initiator_id','message_id']) main_topics= Threads(filters.startdate, filters.enddate, dbcon.identities_db) top_crowded = main_topics.topCrowdedThread(filters.npeople) l_threads = {} l_threads['message_id'] = [] l_threads['people'] = [] l_threads['subject'] = [] l_threads['date'] = [] l_threads['initiator_name'] = [] l_threads['initiator_id'] = [] l_threads['url'] = [] for email_people in top_crowded: email = email_people[0] l_threads['message_id'].append(email.message_id) l_threads['people'].append(email_people[1]) l_threads['subject'].append(email.subject) l_threads['date'].append(email.date.strftime("%Y-%m-%d")) l_threads['initiator_name'].append(email.initiator_name) l_threads['initiator_id'].append(email.initiator_id) l_threads['url'].append(email.url) createJSON(l_threads, "./release/mls_top_crowded_threads.json") createCSV(l_threads, "./release/mls_top_crowded_threads.csv", ['initiator_id','message_id'])
def getLongestThreads(startdate, enddate, identities_db): main_topics = Threads(startdate, enddate, identities_db) longest_threads = main_topics.topLongestThread(10) print "Top longest threads: " l_threads = {} l_threads['message_id'] = [] l_threads['length'] = [] l_threads['subject'] = [] l_threads['date'] = [] l_threads['initiator_name'] = [] l_threads['initiator_id'] = [] for email in longest_threads: l_threads['message_id'].append(email.message_id) l_threads['length'].append(main_topics.lenThread(email.message_id)) l_threads['subject'].append(email.subject) l_threads['date'].append(str(email.date)) l_threads['initiator_name'].append(email.initiator_name) l_threads['initiator_id'].append(email.initiator_id) return l_threads
return l_threads if __name__ == '__main__': logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s') logging.info("Starting Studies analysis") opts = read_options() GrimoireSQL.SetDBChannel(database=opts.dbmls, user=opts.dbuser, password=opts.dbpassword) startdate = opts.initdate enddate = opts.enddate identities_db = opts.dbidentities main_topics = Threads(startdate, enddate, identities_db) # Example of use for the most verbose thread #email = main_topics.verboseThread() #print "The most verbose thread: " #print """ # message_id: %s # subject: %s # date: %s # """ % (email.message_id, email.subject, email.date) # WARNING: This code for senders overwrite previous mls-top.json file bots = [ 'wikibugs', 'gerrit-wm', 'wikibugs_', 'wm-bot', '', 'Translation updater bot', 'jenkins-bot' ]