Commit 1f8571b9 authored by Inkhey's avatar Inkhey

add author view

parent 71f36125
......@@ -90,14 +90,14 @@ class sqlGit(object):
def insert_author(self):
''' 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)
log.stdout.close()
f = sort.stdout.read().decode('utf-8', 'replace')
dAuthor = f.splitlines()
c = self.conn.cursor()
for line in dAuthor:
data = line.split(';;;;')
data = line.split('[;;|\/|;;]')
c.execute(
'''INSERT INTO author(name,email)
values (?,?);''', data)
......@@ -106,14 +106,14 @@ class sqlGit(object):
def insert_commit(self):
''' insert commit data into commits table'''
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)
log.stdout.close()
f = sort.stdout.read().decode('utf-8', 'replace')
dCommit = f.splitlines()
c = self.conn.cursor()
for line in dCommit:
data = line.split(';;;;')
data = line.split('[;;|\/|;;]')
c.execute(
'''INSERT INTO commits(subject,hash,abbrev_hash,date)
values (?,?,?,?);''', data)
......@@ -154,12 +154,12 @@ class sqlGit(object):
link_author_commits table'''
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')
dLinkC_A = f.splitlines()
c = self.conn.cursor()
for line in dLinkC_A:
data = line.split(';;;;')
data = line.split('[;;|\/|;;]')
c.execute(
'''INSERT INTO link_author_commits(author_name,
author_mail,commits)
......@@ -262,7 +262,7 @@ class sqlGit(object):
"" as taille,
"" as dir,
name as name,
"" as email,
email as email,
"author" as type,
name as label
from author;''')
......@@ -291,9 +291,44 @@ class sqlGit(object):
'''View of relation between files'''
pass
def view_authors():
def view_authors(self):
'''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():
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