return ActivityList(list) if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner stdout_utf8() database = DB (url = 'mysql://*****:*****@localhost/', schema = 'vizgrimoire_bicho', schema_id = 'vizgrimoire_cvsanaly') session = database.build_session(Query, echo = False) #--------------------------------- print_banner ("List of openers") res = session.query() \ .select_personsdata("openers") \ .group_by_person() print res for row in res.limit(10).all(): print row.person_id, row.name, row.email #--------------------------------- print_banner ("Activity period for changers") res = session.query() \ .select_personsdata("changers") \ .select_changesperiod() \ .group_by_person() print res for row in res.limit(10).all():
return ActivityList(list) if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner stdout_utf8() database = DB(url='mysql://*****:*****@localhost/', schema='vizgrimoire_cvsanaly', schema_id='vizgrimoire_cvsanaly') session = database.build_session(Query, echo=False) #--------------------------------- print_banner("Number of commits") res = session.query().select_nscmlog(["commits",]) \ .filter_period(start=datetime(2012,9,1), end=datetime(2014,1,1)) print res.scalar() res = session.query().select_nscmlog(["commits",]) \ .filter_nomerges() \ .filter_period(start=datetime(2012,9,1), end=datetime(2014,1,1)) print res.scalar() res = session.query().select_nscmlog(["commits",]) \ .filter_period(end=datetime(2014,1,1)) print res.scalar() #--------------------------------- print_banner("Number of commits, grouped by authors")
if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner from scm import PeriodCondition as SCMPeriodCondition from scm import NomergesCondition as SCMNomergesCondition from datetime import datetime, timedelta stdout_utf8() database = SCMDatabase (url = "mysql://*****:*****@localhost/", schema = "oscon_opennebula_scm_tz", schema_id = "oscon_opennebula_scm_tz") #--------------------------------- print_banner("Author activity per time zone") data = SCMActivityTZ ( datasource = database, name = "authors") tz = data.timezones() print tz #--------------------------------- print_banner("Author activity per time zone (now using session)") session = database.build_session(query_cls = SCMTZQuery) data = SCMActivityTZ ( datasource = session, name = "authors") tz = data.timezones() print tz
return query if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner stdout_utf8() database = DB (url = 'mysql://*****:*****@localhost/', schema = 'reviews_wikimedia_2014_09_11', schema_id = 'vizgrimoire_cvsanaly') session = database.build_session(Query, echo = False) #--------------------------------- print_banner ("List of openers") res = session.query() \ .select_personsdata("openers") \ .group_by_person() print res for row in res.limit(10).all(): print row.person_id, row.name, row.email res = session.query() \ .select_changes() print res for row in res.limit(10).all(): print row.id, row.issue_id, row.patchset, row.field, row.value, row.date res = session.query() \ .select_issues()
from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner from datetime import datetime, timedelta from scm import PeriodCondition as SCMPeriodCondition from scm import NomergesCondition as SCMNomergesCondition from its import PeriodCondition as ITSPeriodCondition stdout_utf8() # SCM database database = SCMDatabase(url="mysql://*****:*****@localhost/", schema="vizgrimoire_cvsanaly", schema_id="vizgrimoire_cvsanaly") session = database.build_session() #--------------------------------- print_banner("List of activity for each author") data = SCMActivityPersons(datasource=database, name="list_authors") activity = data.activity() print activity #--------------------------------- print_banner("Age (days since first activity) for each author.") age = activity.age(datetime(2014, 1, 1)) print age.json() #--------------------------------- print_banner("Idle (days since last activity) for each author.") idle = activity.idle(datetime(2014, 1, 1)) print idle.json() #--------------------------------- print_banner("List of activity for each author (no merges)")
kind = self.actors) if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner from datetime import datetime stdout_utf8() database = DB (url = "mysql://*****:*****@localhost/", schema = "vizgrimoire_cvsanaly", schema_id = "vizgrimoire_cvsanaly") #--------------------------------- print_banner ("Number of commits (timeseries, total)") data = SCM (datasource = database, name = "ncommits") print data.timeseries() print data.total() #--------------------------------- print_banner ("Number of commits (timeseries, total), for period") period = PeriodCondition (start = datetime(2013,1,1), end = None) data = SCM (datasource = database, name = "ncommits", conditions = (period,)) print data.timeseries() print data.total() #--------------------------------- print_banner ("List of commits")
from grimoirelib_alch.query.scm import DB as SCMDatabase from grimoirelib_alch.query.mls import DB as MLSDatabase from scm import NomergesCondition as SCMNomergesCondition from activity_persons import SCMActivityPersons, MLSActivityPersons stdout_utf8() # SCM database database = SCMDatabase (url = "mysql://*****:*****@localhost/", schema = "vizgrimoire_cvsanaly", schema_id = "vizgrimoire_cvsanaly") session = database.build_session() #--------------------------------- print_banner("Age, using entity") nomerges = SCMNomergesCondition() data = SCMActivityPersons (datasource = session, name = "list_ucommitters", conditions = (nomerges,)) age = DurationPersons (datasource = data.activity(), name = "age") print age.durations().json() #--------------------------------- print_banner("Age, using entity and ActivityPersons as datasource") nomerges = SCMNomergesCondition() data = SCMActivityPersons (datasource = session, name = "list_ucommitters", conditions = (nomerges,)) age = DurationPersons (name = "age",
separators=(',', ': '), ensure_ascii=False, encoding="utf8") # Ensure JSON encoder is properly intialized init_json() if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner stdout_utf8() #--------------------------------- print_banner("Period (str, json)") period = Period(datetime(2011, 12, 1), datetime(2012, 11, 1)) print period print jsonpickle.encode(period, unpicklable=False) #--------------------------------- print_banner("ActivityList (str, json)") rowlabels = ["person_id", "name", "firstdate", "lastdate"] list = ActivityList((KeyedTuple( [12, "Fulano Larguiño", datetime(2011, 12, 1), datetime(2012, 11, 1)], labels=rowlabels), KeyedTuple([ 3, "Mengana Corta", datetime(2010, 2, 3),
from grimoirelib_alch.query.its import DB as ITSDatabase from grimoirelib_alch.query.mls import DB as MLSDatabase from grimoirelib_alch.family.activity_persons import ( SCMActivityPersons, ITSActivityPersons, MLSActivityPersons ) from grimoirelib_alch.aux.reports import create_report, add_report stdout_utf8() snapshot_date = datetime(2014,7,1) activity_period = timedelta(days=182) #--------------------------------- print_banner("Demographics with MLS database, MediaWiki") database = MLSDatabase (url = "mysql://*****:*****@localhost/", schema = "mls_wikimedia", schema_id = "scm_wikimedia") # Wikimedia mailing lists don't always keep "arrival_date", therefore # we have to use "fisrt_date". activity = MLSActivityPersons ( datasource = database, name = "list_usenders", date_kind = "check") report = report_demographics (activity_persons = activity, snapshot_date = snapshot_date, activity_period = activity_period, prefix = 'mls-' )
return query if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner stdout_utf8() database = DB(url='mysql://*****:*****@localhost/', schema='reviews_wikimedia_2014_09_11', schema_id='vizgrimoire_cvsanaly') session = database.build_session(Query, echo=False) #--------------------------------- print_banner("List of openers") res = session.query() \ .select_personsdata("openers") \ .group_by_person() print res for row in res.limit(10).all(): print row.person_id, row.name, row.email res = session.query() \ .select_changes() print res for row in res.limit(10).all(): print row.id, row.issue_id, row.patchset, row.field, row.value, row.date res = session.query() \ .select_issues()
query = session.query( label("id", SCMDatabase.Repositories.id) ) \ .filter (SCMDatabase.Repositories.name.in_ (scm_repos_name)) scm_repos = [row.id for row in query.all()] print scm_repos # Get SCM branche ids query = session.query( label("id", SCMDatabase.Branches.id) ) \ .filter (SCMDatabase.Branches.name.in_ (scm_branches_name)) scm_branches = [row.id for row in query.all()] print scm_branches #--------------------------------- print_banner ("SCM_COMMITS_1M: Number of commits during last month") # nomerges = NomergesCondition() # last_month = PeriodCondition (start = month_start, # end = month_end, # date = "author" # ) # master = BranchesCondition (branches = ("master",)) # ncommits = SCM (datasource = session, # name = "ncommits", # conditions = (nomerges, last_month, master)) # values ["scm_commits_1m"] = ncommits.total() # ncommits = SCM (datasource = session, # name = "ncommits", # conditions = (nomerges, master)) # timeseries ["scm_commits_1m"] = ncommits.timeseries()
if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner from datetime import datetime import jsonpickle import csv stdout_utf8() database = DB (url = 'mysql://*****:*****@localhost/', schema = 'oscon_openstack_mls', schema_id = 'oscon_openstack_scm') session = database.build_session(query_cls = Query, echo = False) #--------------------------------- print_banner ("Activity per timezone, raw from database") res = session.query().select_tz() res = res.filter_period(start=datetime(2014,1,1), end=datetime(2014,7,1)) res = res.group_by_tz() print res.all() #--------------------------------- print_banner ("Activity per timezone, raw from database, JSON") print jsonpickle.encode(res.all(), unpicklable=False) #--------------------------------- print_banner ("Activity per timezone, raw, CSV in /tmp/tz.csv") with open ('/tmp/mls-tz.csv', 'wb') as csvfile: tz_writer = csv.writer(csvfile, delimiter=' ',
from grimoirelib_alch.query.scm import DB as SCMDatabase from grimoirelib_alch.query.mls import DB as MLSDatabase from scm import NomergesCondition as SCMNomergesCondition from activity_persons import SCMActivityPersons, MLSActivityPersons stdout_utf8() # SCM database database = SCMDatabase(url="mysql://*****:*****@localhost/", schema="vizgrimoire_cvsanaly", schema_id="vizgrimoire_cvsanaly") session = database.build_session() #--------------------------------- print_banner("Age, using entity") nomerges = SCMNomergesCondition() data = SCMActivityPersons(datasource=session, name="list_ucommitters", conditions=(nomerges, )) age = DurationPersons(datasource=data.activity(), name="age") print age.durations().json() #--------------------------------- print_banner("Age, using entity and ActivityPersons as datasource") nomerges = SCMNomergesCondition() data = SCMActivityPersons(datasource=session, name="list_ucommitters", conditions=(nomerges, )) age = DurationPersons(name="age", datasource=data) print age.durations().json()
from grimoirelib_alch.query.its import DB as ITSDatabase from grimoirelib_alch.query.mls import DB as MLSDatabase from grimoirelib_alch.family.activity_persons import ( SCMActivityPersons, ITSActivityPersons, MLSActivityPersons ) from grimoirelib_alch.aux.reports import create_report, add_report stdout_utf8() snapshot_date = datetime(2014,7,1) activity_period = timedelta(days=182) #--------------------------------- print_banner("Demographics with SCM database, OpenStack") nomerges = SCMNomergesCondition() database = SCMDatabase (url = "mysql://*****:*****@localhost/", schema = "oscon_openstack_scm", schema_id = "oscon_openstack_scm") activity = SCMActivityPersons (datasource = database, name = "list_uauthors", conditions = (nomerges,)) report = report_demographics (activity_persons = activity, snapshot_date = snapshot_date, activity_period = activity_period, prefix = 'scm-') #--------------------------------- print_banner("Demographics with ITS database, OpenStack")
from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner from datetime import datetime, timedelta from scm import PeriodCondition as SCMPeriodCondition from scm import NomergesCondition as SCMNomergesCondition from its import PeriodCondition as ITSPeriodCondition stdout_utf8() # SCM database database = SCMDatabase (url = "mysql://*****:*****@localhost/", schema = "vizgrimoire_cvsanaly", schema_id = "vizgrimoire_cvsanaly") session = database.build_session() #--------------------------------- print_banner("List of activity for each author") data = SCMActivityPersons ( datasource = database, name = "list_authors") activity = data.activity() print activity #--------------------------------- print_banner("Age (days since first activity) for each author.") age = activity.age(datetime(2014,1,1)) print age.json() #--------------------------------- print_banner("Idle (days since last activity) for each author.") idle = activity.idle(datetime(2014,1,1)) print idle.json()
return query.filter_org_ids(list=self.org_ids, kind=self.actors) if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner from datetime import datetime stdout_utf8() database = DB(url="mysql://*****:*****@localhost/", schema="vizgrimoire_cvsanaly", schema_id="vizgrimoire_cvsanaly") #--------------------------------- print_banner("Number of commits (timeseries, total)") data = SCM(datasource=database, name="ncommits") print data.timeseries() print data.total() #--------------------------------- print_banner("Number of commits (timeseries, total), for period") period = PeriodCondition(start=datetime(2013, 1, 1), end=None) data = SCM(datasource=database, name="ncommits", conditions=(period, )) print data.timeseries() print data.total() #--------------------------------- print_banner("List of commits") data = SCM(datasource=database, name="listcommits") print data.list()
) class Query (GrimoireQuery): """Class for dealing with Gerrit-related queries""" if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner stdout_utf8() database = DB (url = 'mysql://*****:*****@localhost/', schema = 'revisorj_test', schema_id = 'revisorj_test') session = database.build_session(Query, echo = False) #--------------------------------- print_banner ("Number of changes, messages, revisions, approvals") res = session.query(label ("changes", func.count (DB.Change.id))) print res.scalar() res = session.query(label ("messages", func.count (DB.Message.uid))) print res.scalar() res = session.query(label ("revisions", func.count (DB.Revision.uid))) print res.scalar() res = session.query(label ("approvals", func.count (DB.Approval.uid))) print res.scalar()
jsonpickle.set_encoder_options('json', sort_keys=True, indent=4, separators=(',', ': '), ensure_ascii=False, encoding="utf8") # Ensure JSON encoder is properly intialized init_json() if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner stdout_utf8() #--------------------------------- print_banner("Period (str, json)") period = Period(datetime(2011,12,1), datetime(2012,11,1)) print period print jsonpickle.encode(period, unpicklable=False) #--------------------------------- print_banner("ActivityList (str, json)") rowlabels = ["person_id", "name", "firstdate", "lastdate"] list = ActivityList((KeyedTuple([12, "Fulano Larguiño", datetime(2011,12,1), datetime(2012,11,1)], labels = rowlabels), KeyedTuple([3, "Mengana Corta", datetime(2010,2,3), datetime(2013,2,3)], labels = rowlabels)))
return ActivityList(list) if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner stdout_utf8() database = DB(url='mysql://*****:*****@localhost/', schema='oscon_openstack_mls', schema_id='oscon_openstack_scm') session = database.build_session(Query, echo=False) #--------------------------------- print_banner("Number of messages which don't have arrival_date") res = session.query().null_arrival().count() print res #--------------------------------- print_banner("List of senders") res = session.query() \ .select_personsdata("senders") for row in res.limit(10).all(): print row.name, row.email #--------------------------------- print_banner("List of senders for a period") res = session.query() \ .select_personsdata("senders") \ .filter_period(start=datetime(2013,9,1),
return ActivityList(list) if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner stdout_utf8() database = DB(url='mysql://*****:*****@localhost/', schema='vizgrimoire_bicho', schema_id='vizgrimoire_cvsanaly') session = database.build_session(Query, echo=False) #--------------------------------- print_banner("List of openers") res = session.query() \ .select_personsdata("openers") \ .group_by_person() print res for row in res.limit(10).all(): print row.person_id, row.name, row.email #--------------------------------- print_banner("Activity period for changers") res = session.query() \ .select_personsdata("changers") \ .select_changesperiod() \ .group_by_person() print res for row in res.limit(10).all():
return ActivityList(list) if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner stdout_utf8() database = DB (url = 'mysql://*****:*****@localhost/', schema = 'vizgrimoire_cvsanaly', schema_id = 'vizgrimoire_cvsanaly') session = database.build_session(Query, echo = False) #--------------------------------- print_banner ("Number of commits") res = session.query().select_nscmlog(["commits",]) \ .filter_period(start=datetime(2012,9,1), end=datetime(2014,1,1)) print res.scalar() res = session.query().select_nscmlog(["commits",]) \ .filter_nomerges() \ .filter_period(start=datetime(2012,9,1), end=datetime(2014,1,1)) print res.scalar() res = session.query().select_nscmlog(["commits",]) \ .filter_period(end=datetime(2014,1,1)) print res.scalar() #--------------------------------- print_banner("Number of commits, grouped by authors")
if __name__ == "__main__": from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner from datetime import datetime import jsonpickle import csv stdout_utf8() database = DB(url='mysql://*****:*****@localhost/', schema='oscon_opennebula_scm_tz', schema_id='oscon_opennebula_scm_tz') session = database.build_session(query_cls=Query, echo=False) #--------------------------------- print_banner("Activity per timezone, raw from database") res = session.query().select_tz() res = res.filter_period(start=datetime(2014, 1, 1), end=datetime(2014, 7, 1)) res = res.group_by_tz() print res print res.all() #--------------------------------- print_banner("Activity per timezone, raw from database, JSON") print jsonpickle.encode(res.all(), unpicklable=False) #--------------------------------- print_banner("Activity per timezone, raw, CSV in /tmp/tz.csv") with open('/tmp/scm-tz.csv', 'wb') as csvfile:
query = session.query( label("id", SCMDatabase.Repositories.id) ) \ .filter (SCMDatabase.Repositories.name.in_ (scm_repos_name)) scm_repos = [row.id for row in query.all()] print scm_repos # Get SCM branche ids query = session.query( label("id", SCMDatabase.Branches.id) ) \ .filter (SCMDatabase.Branches.name.in_ (scm_branches_name)) scm_branches = [row.id for row in query.all()] print scm_branches #--------------------------------- print_banner("SCM_COMMITS_1M: Number of commits during last month") # nomerges = NomergesCondition() # last_month = PeriodCondition (start = month_start, # end = month_end, # date = "author" # ) # master = BranchesCondition (branches = ("master",)) # ncommits = SCM (datasource = session, # name = "ncommits", # conditions = (nomerges, last_month, master)) # values ["scm_commits_1m"] = ncommits.total() # ncommits = SCM (datasource = session, # name = "ncommits", # conditions = (nomerges, master)) # timeseries ["scm_commits_1m"] = ncommits.timeseries()