[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[snapshot/master] Add a project/trace/snapshot-master.debian.org trace file



---
 web/app/snapshot/config/routing.py      |    2 +
 web/app/snapshot/controllers/misc.py    |   33 +++++++++++++++++++++++++++++++
 web/app/snapshot/model/snapshotmodel.py |   11 ++++++++++
 3 files changed, 46 insertions(+), 0 deletions(-)
 create mode 100644 web/app/snapshot/controllers/misc.py

diff --git a/web/app/snapshot/config/routing.py b/web/app/snapshot/config/routing.py
index 329d6c1..8e5a48e 100644
--- a/web/app/snapshot/config/routing.py
+++ b/web/app/snapshot/config/routing.py
@@ -50,6 +50,8 @@ def make_map():
     map.connect('/removal/', controller='removal', action='root')
     map.connect('/removal/{id}', controller='removal', action='one')
 
+    map.connect('/project/trace/snapshot-master.debian.org', controller='misc', action='trace')
+
     #map.connect('/{controller}/{action}')
     #map.connect('/{controller}/{action}/{id}')
 
diff --git a/web/app/snapshot/controllers/misc.py b/web/app/snapshot/controllers/misc.py
new file mode 100644
index 0000000..8adb34e
--- /dev/null
+++ b/web/app/snapshot/controllers/misc.py
@@ -0,0 +1,33 @@
+import logging
+
+from pylons import request, response, session, tmpl_context as c, g, config
+from pylons.controllers.util import abort, redirect_to
+
+from snapshot.lib.base import BaseController, render
+
+from snapshot.lib.dbinstance import DBInstance
+from snapshot.lib.control_helpers import *
+
+log = logging.getLogger(__name__)
+
+class MiscController(BaseController):
+    def trace(self):
+        db = None
+        try:
+            db = DBInstance(g.pool)
+            set_expires(int(config['app_conf']['expires.root']))
+
+            last = g.shm.get_last_mirrorrun(db)
+
+            content = []
+            content.append("%s\n"%(last.ctime()))
+            content.append("# Above timestamp is timestamp of latest mirrrorrun\n")
+
+            response.content_type = 'text/plain'
+            return content
+        finally:
+            if not db is None: db.close()
+
+# vim:set et:
+# vim:set ts=4:
+# vim:set shiftwidth=4:
diff --git a/web/app/snapshot/model/snapshotmodel.py b/web/app/snapshot/model/snapshotmodel.py
index 2127505..a9965d9 100644
--- a/web/app/snapshot/model/snapshotmodel.py
+++ b/web/app/snapshot/model/snapshotmodel.py
@@ -359,6 +359,17 @@ class SnapshotModel:
         rows = db.query("""SELECT hash FROM removal_affects WHERE removal_log_id=%(removal_log_id)s""", {'removal_log_id': id})
         return map(lambda x: x['hash'], rows)
 
+
+    def get_last_mirrorrun(self, db):
+        row = db.query_one("""
+                SELECT max(run)::TIMESTAMP WITH TIME ZONE AS run
+                  FROM mirrorrun
+                  """)
+        if row is None:
+            return None
+
+        return row['run']
+
 # vim:set et:
 # vim:set ts=4:
 # vim:set shiftwidth=4:
-- 
1.5.6.5


Reply to: