From bfa3622c23c4bc574e6e51bdd8c196604ebcd172 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Sun, 6 Feb 2022 01:09:01 -0300 Subject: Attempt to add pinned repos --- ganarchy/db.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'ganarchy/db.py') diff --git a/ganarchy/db.py b/ganarchy/db.py index 14d0d47..a8bcc8d 100644 --- a/ganarchy/db.py +++ b/ganarchy/db.py @@ -164,7 +164,8 @@ class Database: "active" INT, "branch" TEXT, "project" TEXT, - "federate" INT + "federate" INT, + "pinned" INT ) ''') c.execute(''' @@ -184,8 +185,8 @@ class Database: ): if repo.active: c.execute( - '''INSERT INTO "repos" VALUES (?, ?, ?, ?, ?)''', - (repo.uri, 1, repo.branch, repo.project_commit, int(repo.federate)) + '''INSERT INTO "repos" VALUES (?, ?, ?, ?, ?, ?)''', + (repo.uri, 1, repo.branch, repo.project_commit, int(repo.federate), int(repo.pinned)) ) self.conn.commit() c.close() @@ -259,9 +260,14 @@ class Database: """ c = self.conn.cursor() try: - for (e, url, branch, head_commit) in c.execute( + for (e, url, branch, head_commit, pinned) in c.execute( ''' - SELECT "max"("e"), "url", "branch", "head_commit" + SELECT + "max"("e"), + "url", + "branch", + "head_commit", + "pinned" FROM ( SELECT "max"("T1"."entry") "e", @@ -282,13 +288,20 @@ class Database: SELECT null, "T3"."url", "T3"."branch", null FROM "repos" "T3" WHERE "active" AND "project" IS ?1 - ) + ) JOIN ( + SELECT + "T4"."url" "purl", + "T4"."branch" "pbranch", + "T4"."pinned" + FROM "repos" "T4" + WHERE "project" IS ?1 + ) ON ("url" IS "purl" AND "branch" IS "pbranch") GROUP BY "url", "branch" ORDER BY "e" ''', (project_commit,) ): - yield url, branch, head_commit + yield url, branch, head_commit, pinned finally: c.close() -- cgit 1.4.1