From 248f2efd8ac7c1d204542ab6bf77d386cc005508 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Mon, 1 Jun 2009 17:23:31 +0000 Subject: Snapshots: Add --date for detailed view for a particular date Signed-off-by: Sol Jerome git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5266 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Snapshots/model.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/lib/Server/Snapshots/model.py') diff --git a/src/lib/Server/Snapshots/model.py b/src/lib/Server/Snapshots/model.py index e5306da64..cd2e617f5 100644 --- a/src/lib/Server/Snapshots/model.py +++ b/src/lib/Server/Snapshots/model.py @@ -249,3 +249,12 @@ class Snapshot(Base): @classmethod def get_current(cls, session, clientname): return session.query(Snapshot).join(Snapshot.client_metadata, Metadata.client).filter(Client.name==clientname).order_by(desc(Snapshot.timestamp)).first() + + @classmethod + def get_by_date(cls, session, clientname, timestamp): + return session.query(Snapshot)\ + .join(Snapshot.client_metadata, Metadata.client)\ + .filter(Snapshot.timestamp < timestamp)\ + .filter(Client.name==clientname)\ + .order_by(desc(Snapshot.timestamp))\ + .first() -- cgit v1.2.3-1-g7c22