Compare commits
3 Commits
9b983f9862
...
105164e661
Author | SHA1 | Date |
---|---|---|
SoniEx2 | 105164e661 | |
SoniEx2 | 429d3d5b30 | |
SoniEx2 | ef60898514 |
12
ganarchy.py
12
ganarchy.py
|
@ -87,6 +87,7 @@ def initdb():
|
|||
c.execute('''CREATE TABLE repos (url TEXT PRIMARY KEY, active INT)''')
|
||||
c.execute('''CREATE INDEX active_key ON repos (active)''')
|
||||
c.execute('''CREATE TABLE repo_history (entry INTEGER PRIMARY KEY ASC AUTOINCREMENT, url TEXT, count INTEGER, head_commit TEXT)''')
|
||||
c.execute('''CREATE INDEX url_key ON repo_history (url)''')
|
||||
c.execute('''CREATE TABLE config (git_commit TEXT, project_title TEXT)''')
|
||||
c.execute('''INSERT INTO config VALUES ('', '')''')
|
||||
conn.commit()
|
||||
|
@ -197,15 +198,22 @@ def cron_target():
|
|||
(project_commit, project_title) = c.fetchone()
|
||||
entries = []
|
||||
generate_html = []
|
||||
for (url,) in c.execute("""SELECT url FROM repos WHERE active == 1"""):
|
||||
for (e, url,) in c.execute("""SELECT max(e), url FROM (SELECT max(T1.entry) e, T1.url FROM repo_history T1
|
||||
WHERE (SELECT active FROM repos T2 WHERE url = T1.url)
|
||||
GROUP BY T1.url
|
||||
UNION
|
||||
SELECT null, T3.url FROM repos T3 WHERE active)
|
||||
GROUP BY url ORDER BY e"""):
|
||||
result = handle_target(url, project_commit)
|
||||
if result is not None:
|
||||
count, post_hash, msg = result
|
||||
entries.append((url, count, post_hash))
|
||||
generate_html.append((url, msg, count))
|
||||
# sort stuff twice because reasons
|
||||
entries.sort(key=lambda x: x[1], reverse=True)
|
||||
generate_html.sort(key=lambda x: x[2], reverse=True)
|
||||
c.executemany('''INSERT INTO repo_history VALUES (NULL, ?, ?, ?)''', entries)
|
||||
conn.commit()
|
||||
generate_html.sort(key=lambda x: x[2]) # sort by count
|
||||
html_entries = []
|
||||
for (url, msg, count) in generate_html:
|
||||
history = c.execute('''SELECT count FROM repo_history WHERE url == ? ORDER BY entry ASC''', (url,)).fetchall()
|
||||
|
|
Loading…
Reference in New Issue