X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=monitor%2Fdatabase%2Finfo%2Faction.py;h=6554de83a23faa08b795bda48be523aef147e980;hb=45fea95bb898f254ea7e987d7417e9091885fbee;hp=0abec62c9d50094cb40666a513ffb336d33b2ad6;hpb=c9d06f3b274ecbc092a0b3eb1f5ceb6c0f734aad;p=monitor.git diff --git a/monitor/database/info/action.py b/monitor/database/info/action.py index 0abec62..6554de8 100644 --- a/monitor/database/info/action.py +++ b/monitor/database/info/action.py @@ -67,9 +67,9 @@ class BlacklistRecord(Entity): return False else: if self.date_created + timedelta(0,self.expires) > datetime.now(): - return True - else: return False + else: + return True def willExpire(self): if self.neverExpires(): @@ -83,7 +83,12 @@ class ActionRecord(Entity): # TODO: need to sort on 'round' since actions will not be globally sync'd. return cls.query.filter_by(**kwargs).order_by(ActionRecord.id.desc()).first() -# ACCOUNTING + @classmethod + def delete_recent_by(cls, since, **kwargs): + acts = cls.query.filter_by(**kwargs).filter(cls.date_created >= datetime.now() - timedelta(since)).order_by(cls.date_created.desc()) + for i in acts: i.delete() + + # ACCOUNTING date_created = Field(DateTime,default=datetime.now) loginbase = Field(String,default=None) hostname = Field(String,default=None) @@ -107,6 +112,8 @@ class ActionRecord(Entity): # NOTE: in case an exception is thrown while trying to perform an action. error_string = Field(String, default=None) + log_path = Field(String, default=None) + #issue = ManyToOne('IssueRecord') # NOTE: this is the parent relation to fb records. first create the # action record, then append to this value all of the findbad records we