Commit 1f8571b9 authored by Inkhey's avatar Inkhey
Browse files

add author view

parent 71f36125
...@@ -90,14 +90,14 @@ class sqlGit(object): ...@@ -90,14 +90,14 @@ class sqlGit(object):
def insert_author(self): def insert_author(self):
''' insert author data into author table''' ''' insert author data into author table'''
log = Popen("git log --format=%aN;;;;%aE".split(), stdout=PIPE) log = Popen("git log --format=%aN[;;|\/|;;]%aE".split(), stdout=PIPE)
sort = Popen("sort -u".split(), stdin=log.stdout, stdout=PIPE) sort = Popen("sort -u".split(), stdin=log.stdout, stdout=PIPE)
log.stdout.close() log.stdout.close()
f = sort.stdout.read().decode('utf-8', 'replace') f = sort.stdout.read().decode('utf-8', 'replace')
dAuthor = f.splitlines() dAuthor = f.splitlines()
c = self.conn.cursor() c = self.conn.cursor()
for line in dAuthor: for line in dAuthor:
data = line.split(';;;;') data = line.split('[;;|\/|;;]')
c.execute( c.execute(
'''INSERT INTO author(name,email) '''INSERT INTO author(name,email)
values (?,?);''', data) values (?,?);''', data)
...@@ -106,14 +106,14 @@ class sqlGit(object): ...@@ -106,14 +106,14 @@ class sqlGit(object):
def insert_commit(self): def insert_commit(self):
''' insert commit data into commits table''' ''' insert commit data into commits table'''
log = Popen( log = Popen(
"git log --format=%s;;;;%H;;;;%t;;;;%at".split(), stdout=PIPE) "git log --format=%s[;;|\/|;;]%H[;;|\/|;;]%t[;;|\/|;;]%at".split(), stdout=PIPE)
sort = Popen("sort -u".split(), stdin=log.stdout, stdout=PIPE) sort = Popen("sort -u".split(), stdin=log.stdout, stdout=PIPE)
log.stdout.close() log.stdout.close()
f = sort.stdout.read().decode('utf-8', 'replace') f = sort.stdout.read().decode('utf-8', 'replace')
dCommit = f.splitlines() dCommit = f.splitlines()
c = self.conn.cursor() c = self.conn.cursor()
for line in dCommit: for line in dCommit:
data = line.split(';;;;') data = line.split('[;;|\/|;;]')
c.execute( c.execute(
'''INSERT INTO commits(subject,hash,abbrev_hash,date) '''INSERT INTO commits(subject,hash,abbrev_hash,date)
values (?,?,?,?);''', data) values (?,?,?,?);''', data)
...@@ -154,12 +154,12 @@ class sqlGit(object): ...@@ -154,12 +154,12 @@ class sqlGit(object):
link_author_commits table''' link_author_commits table'''
log = Popen( log = Popen(
'git log --pretty=format:%aN;;;;%aE;;;;%H'.split(), stdout=PIPE) 'git log --pretty=format:%aN[;;|\/|;;]%aE[;;|\/|;;]%H'.split(), stdout=PIPE)
f = log.stdout.read().decode('utf-8', 'replace') f = log.stdout.read().decode('utf-8', 'replace')
dLinkC_A = f.splitlines() dLinkC_A = f.splitlines()
c = self.conn.cursor() c = self.conn.cursor()
for line in dLinkC_A: for line in dLinkC_A:
data = line.split(';;;;') data = line.split('[;;|\/|;;]')
c.execute( c.execute(
'''INSERT INTO link_author_commits(author_name, '''INSERT INTO link_author_commits(author_name,
author_mail,commits) author_mail,commits)
...@@ -262,7 +262,7 @@ class sqlGit(object): ...@@ -262,7 +262,7 @@ class sqlGit(object):
"" as taille, "" as taille,
"" as dir, "" as dir,
name as name, name as name,
"" as email, email as email,
"author" as type, "author" as type,
name as label name as label
from author;''') from author;''')
...@@ -291,9 +291,44 @@ class sqlGit(object): ...@@ -291,9 +291,44 @@ class sqlGit(object):
'''View of relation between files''' '''View of relation between files'''
pass pass
def view_authors(): def view_authors(self):
'''View of relation between authors''' '''View of relation between authors'''
pass c = self.conn.cursor()
c.execute('''
create view nodes as
select distinct( name || email) as id,
name as name,
email as email,
name as label
from author;''')
c.execute('''
create view edges as
select a1.author AS source , a2.author AS target,
count(a1.file) as nbfile,
count(a1.file) as weight,
a1.file as label
from
(
(select
a.author_name || a.author_mail as author,
f.dir || f.file as file
from link_file_commits f, link_author_commits a
where ( f.commits=a.commits)
)as a1
join
(select
a.author_name || a.author_mail as author,
f.dir || f.file as file
from link_file_commits f, link_author_commits a
where ( f.commits=a.commits)
)as a2
on a1.file = a2.file
and a1.author != a2.author
)
group by a1.author,a2.author
;''')
self.conn.commit()
def view_file_commits(): def view_file_commits():
pass pass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment