summaryrefslogtreecommitdiff
path: root/morphcacheserver/artifact_database.py
diff options
context:
space:
mode:
Diffstat (limited to 'morphcacheserver/artifact_database.py')
-rw-r--r--morphcacheserver/artifact_database.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/morphcacheserver/artifact_database.py b/morphcacheserver/artifact_database.py
index 9bc35a9..b9550a1 100644
--- a/morphcacheserver/artifact_database.py
+++ b/morphcacheserver/artifact_database.py
@@ -141,6 +141,24 @@ class ArtifactDatabase(object):
'hash_sha1': hash_sha1
}
+ def count_artifacts(self):
+ '''Return the number of known artifacts.
+
+ This may include artifacts where the actual files aren't stored in the
+ cache, as we allow submitting just the hash in order to check
+ reproducibility.
+
+ '''
+ n_artifacts_sql = '''
+ SELECT COUNT(cache_name) FROM artifact_files
+ '''
+
+ cursor = self.db.cursor()
+ logging.debug('Running: %s', n_artifacts_sql)
+ cursor.execute(n_artifacts_sql)
+
+ return cursor.fetchone()[0]
+
def view_artifact_statistics(self, start=0, page_size=50):
'''Return information on number of builds for each artifact.