diff options
author | jwansek <eddie.atten.ea29@gmail.com> | 2025-04-07 14:56:02 -0400 |
---|---|---|
committer | jwansek <eddie.atten.ea29@gmail.com> | 2025-04-07 14:56:02 -0400 |
commit | f422d957177563a89a4b7792fe395588bb157e10 (patch) | |
tree | 68455d0ac7ac52bb1ae22cf6a914ed8190c02267 | |
parent | cf227d4434bbcb47e7a2862a777cc579fefdb1a8 (diff) | |
download | eda.gay-f422d957177563a89a4b7792fe395588bb157e10.tar.gz eda.gay-f422d957177563a89a4b7792fe395588bb157e10.zip |
Fixed bug where there could be duplicate git commits
-rwxr-xr-x | app.py | 2 | ||||
-rw-r--r-- | database.py | 11 |
2 files changed, 7 insertions, 6 deletions
@@ -70,7 +70,7 @@ def index(): **get_template_items("eden's site :3", db), markdown = parser.parse_text(f.read())[0], featured_thoughts = db.get_featured_thoughts(), - commits = db.get_cached_commits()[:7], + commits = db.get_cached_commits()[:10], sidebar_img = get_sidebar_img(db) ) diff --git a/database.py b/database.py index e68e085..d5327e4 100644 --- a/database.py +++ b/database.py @@ -149,9 +149,9 @@ class Database: threading.Thread(target = update_cache).start() with self.__connection.cursor() as cursor: if since is not None: - cursor.execute("SELECT message, url, commitTime, additions, deletions, total FROM commitCache WHERE commitTime > %s ORDER BY commitTime DESC;", (since, )) + cursor.execute("SELECT DISTINCT message, url, commitTime, additions, deletions, total FROM commitCache WHERE commitTime > %s ORDER BY commitTime DESC;", (since, )) else: - cursor.execute("SELECT message, url, commitTime, additions, deletions, total FROM commitCache ORDER BY commitTime DESC;") + cursor.execute("SELECT DISTINCT message, url, commitTime, additions, deletions, total FROM commitCache ORDER BY commitTime DESC;") # i think i might have spent too long doing functional programming return [{ "repo": urlparse(i[1]).path.split("/")[2], @@ -174,9 +174,10 @@ class Database: def update_commit_cache(self, requested): with self.__connection.cursor() as cursor: - cursor.execute("SELECT DISTINCT url FROM commitCache;") - urls = [i[0] for i in cursor.fetchall()] for commit in requested: + cursor.execute("SELECT DISTINCT url FROM commitCache;") + urls = [i[0] for i in cursor.fetchall()] + if commit["url"] not in urls: cursor.execute(""" INSERT INTO commitCache (message, url, commitTime, additions, deletions, total) @@ -245,7 +246,7 @@ def update_cache(): if __name__ == "__main__": - # update_cache() + update_cache() import json with Database() as db: print(db.get_cached_commits()[0]) |