Exemplo n.º 1
0
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
Exemplo n.º 2
0
def set_db_channel(user='******',
                   password='',
                   database=None,
                   host="127.0.0.1",
                   port=3306,
                   group=None):
    SetDBChannel(user, password, database, host, port, group)
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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'])
Exemplo n.º 5
0
def create_people_identifiers(startdate, enddate, destdir, npeople,
                              identities_db):
    from vizgrimoire.GrimoireUtils import check_array_values
    logging.info("Generating people identifiers")

    people = get_top_report(startdate,
                            enddate,
                            npeople,
                            identities_db,
                            only_people=True)
    people_ids = []  # upeople_ids which need identifiers
    people_data = {}  # identifiers for upeople_ids
    ds_scm = Report.get_data_source("scm")
    if ds_scm is None:
        # Without SCM (identities) data source can not continue
        return

    for ds in Report.get_data_sources():
        periods = [".", ".last year", ".last month"]
        top_names = ds.get_top_metrics()
        for period in periods:
            for top_name in top_names:
                if top_name + period in people[ds.get_name()]:
                    if 'id' in people[ds.get_name()][top_name + period]:
                        people_ids += check_array_values(
                            people[ds.get_name()][top_name + period])['id']
    people_ids = list(set(people_ids))

    from vizgrimoire.SCM import GetPeopleListSCM
    import vizgrimoire.People as People
    from vizgrimoire.GrimoireSQL import SetDBChannel

    # TODO: Identities db is the same than SCM
    Report.connect_ds(ds_scm)

    for upeople_id in people_ids:
        people_data[upeople_id] = People.GetPersonIdentifiers(
            identities_db, upeople_id)

    all_top_min_ds = get_top_people(startdate, enddate, identities_db)

    db = automator['generic']['db_cvsanaly']
    SetDBChannel(database=db, user=opts.dbuser, password=opts.dbpassword)

    for upeople_id in all_top_min_ds:
        people_data[upeople_id] = People.GetPersonIdentifiers(
            identities_db, upeople_id)

    createJSON(people_data, destdir + "/people.json")

    return people_ids
Exemplo n.º 6
0
 def connect_ds(ds):
     db = Report._automator['generic'][ds.get_db_name()]
     dbuser = Report._automator['generic']['db_user']
     dbpassword = Report._automator['generic']['db_password']
     SetDBChannel(database=db, user=dbuser, password=dbpassword)