Commit 707b21ba authored by inkhey's avatar inkhey

add better time support

parent 271b1a82
......@@ -69,9 +69,28 @@ class sqlGit(object):
dir text,
commits text,
foreign key (file,dir)
references author(name,dir),
references file(name,dir),
foreign key (commits)
references commits(hash));''')
# save last and first commit date for file and author
c.execute('''CREATE TABLE date_file(
file text,
dir text,
deb_date integer,
fin_date integer,
foreign key (file,dir)
references file(name,dir)
);''')
c.execute('''CREATE TABLE date_author(
name text,
email text,
deb_date integer,
fin_date integer,
foreign key (name,email)
references author(name,email)
);''')
self.conn.commit()
# INSERT
......@@ -85,6 +104,7 @@ class sqlGit(object):
self.insert_file(depth)
self.insert_link_A_C()
self.insert_link_F_C()
self.insert_dates()
self.delete_unused_file()
def insert_author(self):
......@@ -194,35 +214,59 @@ class sqlGit(object):
values (?,?,?);''', data)
self.conn.commit()
# VIEW
def insert_dates(self):
c = self.conn.cursor()
c.execute(
'''INSERT INTO date_file(deb_date,fin_date,file,dir)
Select min(c.date),max(c.date),lfc.file,lfc.dir
from link_file_commits lfc join commits c
on c.hash=lfc.commits
group by lfc.file,lfc.dir;'''
)
c.execute(
'''INSERT INTO date_author(deb_date,fin_date,name,email)
Select min(c.date),max(c.date),lac.author_name,lac.author_mail
from link_author_commits lac join commits c
on c.hash=lac.commits
group by lac.author_name,lac.author_mail;'''
)
self.conn.commit()
def view_3nodestype(self):
'''View with 3 types of nodes : author,commit,file'''
c = self.conn.cursor()
c.execute(
'''create view nodes as
select dir || name as id ,
size as taille,
dir as dir,
select f.dir || f.name as id ,
f.size as taille,
f.dir as dir,
"" as name,
"" as email,
"" as subject,
"" as abbrev_hash,
"" as date,
"file" as type,
dir || name as label
from file
datetime(df.deb_date, 'unixepoch') as deb_date,
datetime(df.fin_date,'unixepoch') as fin_date,
"fichier" as type,
f.dir || f.name as label
from file f join date_file df
where f.dir=df.dir
and f.name=df.file
union
select name || email as id,
select a.name || a.email as id,
"" as taille,
"" as dir,
name as name,
email as email,
a.name as name,
a.email as email,
"" as subject,
"" as abbrev_hash,
"" as date,
datetime(da.deb_date, 'unixepoch') as deb_date,
datetime(da.fin_date,'unixepoch') as fin_date,
"author" as type,
name as label
from author
a.name as label
from author a join date_author da
where a.email=da.email
and a.name=da.name
union
select hash as id,
"" as taille,
......@@ -231,7 +275,8 @@ class sqlGit(object):
"" as email,
subject as subject,
abbrev_hash as abbrev_hash,
datetime(date, 'unixepoch') as date,
datetime(date, 'unixepoch') as date_deb,
datetime(date, 'unixepoch') as date_fin,
"commit" as type,
abbrev_hash as label
from commits;
......@@ -257,23 +302,31 @@ class sqlGit(object):
c = self.conn.cursor()
c.execute('''create view nodes as
select dir || name as id ,
size as taille,
dir as dir,
select f.dir || f.name as id ,
f.size as taille,
f.dir as dir,
"" as name,
"" as email,
"file" as type,
dir || name as label
from file
datetime(df.deb_date, 'unixepoch') as deb_date,
datetime(df.fin_date,'unixepoch') as fin_date,
"fichier" as type,
f.dir || f.name as label
from file f join date_file df
where f.dir=df.dir
and f.name=df.file
union
select name || email as id,
select a.name || a.email as id,
"" as taille,
"" as dir,
name as name,
email as email,
a.name as name,
a.email as email,
datetime(da.deb_date, 'unixepoch') as deb_date,
datetime(da.fin_date,'unixepoch') as fin_date,
"author" as type,
name as label
from author;''')
a.name as label
from author a join date_author da
where a.email=da.email
and a.name=da.name''')
c.execute(''' create view edges as
select
......@@ -300,11 +353,15 @@ class sqlGit(object):
c = self.conn.cursor()
c.execute('''create view nodes as
select dir || name as id ,
size as taille,
dir as dir,
dir || name as label
from file;''')
select f.dir || f.name as id ,
f.size as taille,
f.dir as dir,
datetime(df.deb_date, 'unixepoch') as deb_date,
datetime(df.fin_date,'unixepoch') as fin_date,
f.dir || f.name as label
from file f join date_file df
where f.dir=df.dir
and f.name=df.file;''')
c.execute('''
create view edges as
......@@ -339,11 +396,15 @@ class sqlGit(object):
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;''')
select distinct( a.name || a.email) as id,
a.name as name,
a.email as email,
a.name as label,
datetime(da.deb_date, 'unixepoch') as deb_date,
datetime(da.fin_date,'unixepoch') as fin_date
from author a join date_author da
where a.email=da.email
and a.name=da.name;''')
c.execute('''
create view edges as
......@@ -401,7 +462,7 @@ class sqlGit(object):
c = self.conn.cursor()
listTable = ('author', 'commits', 'file', 'link_author_commits',
'link_file_commits')
'link_file_commits','date_author','date_file')
for table in listTable:
c.execute('DROP TABLE IF EXISTS ' + table + ' ;')
self.conn.commit()
......
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