]> pd.if.org Git - zpackage/commitdiff
add view to count file refs
authorNathan Wagner <nw@hydaspes.if.org>
Sat, 3 Nov 2018 14:28:54 +0000 (14:28 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sat, 3 Nov 2018 14:49:45 +0000 (14:49 +0000)
db.sql

diff --git a/db.sql b/db.sql
index 00c5df0f6f1e316c964dd380fe84570f95cbc169..427c1ef4d586a3c6e26ca8871749e573a7732684 100644 (file)
--- a/db.sql
+++ b/db.sql
@@ -15,6 +15,15 @@ CREATE TABLE files (
 )
 ;
 
+create view filerefs as
+select F.hash, count(PF.hash) + count(S.hash) + count(EL.file) as refcount
+from files F
+left join packagefiles PF on PF.hash = F.hash
+left join scripts S on S.hash = F.hash
+left join elflibraries EL on EL.file = F.hash
+group by F.hash
+;
+
 -- information about packages
 -- a package is identified by a package,version,release triple
 create table packages (