Skip to content

Commit

Permalink
Workaround to avoid SCM repository names duplicates due to cvsanaly bug
Browse files Browse the repository at this point in the history
Workaround to get SCM repository names using uri instead of name
due to bug MetricsGrimoire/CVSAnalY#100
  • Loading branch information
canasdiaz committed Feb 4, 2016
1 parent 83cb217 commit 4ad7180
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
20 changes: 5 additions & 15 deletions vizgrimoire/SCM.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ def create_filter_report_top(filter_, period, startdate, enddate, destdir, npeop
items = [items]

fn = os.path.join(destdir, filter_.get_filename(SCM()))
createJSON(items, fn)
escaped_items = [i.replace('/','_') for i in items]
createJSON(escaped_items, fn)

for item in items :
item_name = "'"+ item+ "'"
Expand All @@ -276,12 +277,9 @@ def create_filter_report(filter_, period, startdate, enddate, destdir, npeople,
items = [items]

fn = os.path.join(destdir, filter_.get_filename(SCM()))
createJSON(items, fn)

if filter_name in ("domain", "company", "repository"):
items_list = {'name' : [], 'commits_365' : [], 'authors_365' : []}
else:
items_list = items
escaped_items = [i.replace('/','_') for i in items]
logging.info("D1")
createJSON(escaped_items, fn)

for item in items :
item_name = "'"+ item+ "'"
Expand All @@ -296,16 +294,8 @@ def create_filter_report(filter_, period, startdate, enddate, destdir, npeople,
fn = os.path.join(destdir, filter_item.get_static_filename(SCM()))
createJSON(agg, fn)

if filter_name in ("domain", "company", "repository"):
items_list['name'].append(item.replace('/', '_'))
items_list['commits_365'].append(agg['commits_365'])
items_list['authors_365'].append(agg['authors_365'])

SCM.create_filter_report_top(filter_, period, startdate, enddate, destdir, npeople, identities_db)

fn = os.path.join(destdir, filter_.get_filename(SCM()))
createJSON(items_list, fn)

if (filter_name == "company"):
ds = SCM
#summary = SCM.get_filter_summary(filter_, period, startdate, enddate, identities_db, 10)
Expand Down
3 changes: 3 additions & 0 deletions vizgrimoire/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,9 @@ def convert_all_to_single(cls, data, filter_, destdir, evolutionary, period='mon
if cls == ITS or cls == SCM:
if filter_.get_name() in ["company+country","company+project"]:
data['name'] = data.pop('filter')
data['name'] = [item.replace('/', '_') for item in data['name']]
if cls == SCM:
data['name'] = [item.replace('/', '_') for item in data['name']]

if not evolutionary:
# First create the JSON with the list of items
Expand Down
6 changes: 3 additions & 3 deletions vizgrimoire/metrics/query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def get_group_field (ds_query, filter_type):
if ds_query == MLSQuery:
field = "DISTINCT(SUBSTR(mp.email_address,LOCATE('@',mp.email_address)+1)) as name"
elif analysis == "repository":
field = "r.name"
field = "r.uri AS name"
if ds_query == ITSQuery: field = "t.url"
elif ds_query == SCRQuery: field = "t.url"
elif ds_query == MLSQuery: field = "ml.mailing_list_url"
Expand Down Expand Up @@ -500,11 +500,11 @@ def GetSQLRepositoriesWhere (self, repository):
if isinstance(repository, list):
repo_filter = "("
for repo in repository:
repo_filter = repo_filter + "r.name = " + repo + " or "
repo_filter = repo_filter + "r.uri = " + repo + " or "
repo_filter = repo_filter[:-4] + ")"
fields.add(repo_filter)
elif repository is not None:
fields.add("r.name = "+ repository)
fields.add("r.uri = "+ repository)

return fields

Expand Down
2 changes: 1 addition & 1 deletion vizgrimoire/metrics/scm_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ def _get_sql(self, evolutionary):
def get_list(self):
"""Repositories list ordered by number of commits"""
q = """
select count(distinct(sid)) as total, name
select count(distinct(sid)) as total, r.uri AS name
from repositories r, (
select distinct(s.id) as sid, repository_id from actions a, scmlog s
where s.id = a.commit_id and s.author_date >=%s and s.author_date < %s) t
Expand Down

0 comments on commit 4ad7180

Please sign in to comment.