Commit 707b21ba authored by inkhey's avatar inkhey
Browse files

add better time support

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