(
        self, method=None, hid=None,
            time=None, start=None, limit=None, rdb=None)
return retdata
This will pull a monitors history from rethinkDB
This will pull a monitors history from rethinkDB
This will pull a monitors history from rethinkDB
def history(
        self, method=None, hid=None,
            time=None, start=None, limit=None, rdb=None):
        ''' This will pull a monitors history from rethinkDB '''
        retdata = False
        if method == "mon-history":
            retdata = []
            monitors = r.table('history').filter(
                (r.row['cid'] == self.cid) & (r.row['starttime'] >= time) & (r.row['type'] == "monitor")).order_by(
                r.desc('starttime')).pluck('starttime', 'id', 'cid', 'zone', 'status', 'failcount', 'method', 'name').skip(start).limit(limit).run(rdb)
            for mon in monitors:
                mon['starttime'] = datetime.datetime.fromtimestamp(
                    mon['starttime']).strftime('%Y-%m-%d %H:%M:%S')
                retdata.append(mon)
        elif method == "detail-history":
            retdata = []
            mon = r.table('history').get(hid).pluck(
                'starttime', 'cid', 'zone', 'status',
                'failcount', 'method', 'name').run(rdb)
            mon['reactions'] = []
            reactions = r.table('history').filter(
                (r.row['cid'] == self.cid) & (r.row['starttime'] == mon['starttime']) & (r.row['zone'] == mon['zone']) & (r.row['type'] == "reaction")).pluck('name', 'rstatus', 'time', 'starttime').run(rdb)
            for react in reactions:
                react['starttime'] = datetime.datetime.fromtimestamp(
                    react['starttime']).strftime('%Y-%m-%d %H:%M:%S')
                react['time'] = datetime.datetime.fromtimestamp(
                    react['time']).strftime('%Y-%m-%d %H:%M:%S')
                mon['reactions'].append(react)
            mon['starttime'] = datetime.datetime.fromtimestamp(
                mon['starttime']).strftime('%Y-%m-%d %H:%M:%S')
            retdata.append(mon)
        elif method == "count":
            retdata = r.table('history').filter(
                (r.row['cid'] == self.cid) & (r.row['starttime'] >= time) & (r.row['type'] == "monitor")).count().run(rdb)
        return retdata
def history ( self , method = None , hid = None , time = None , start = None , limit = None , rdb = None ) : retdata = False if method == "mon-history" : retdata = [ ] monitors = r . table ( 'history' ) . filter ( ( r . row [ 'cid' ] == self . cid ) & ( r . row [ 'starttime' ] >= time ) & ( r . row [ 'type' ] == "monitor" ) ) . order_by ( r . desc ( 'starttime' ) ) . pluck ( 'starttime' , 'id' , 'cid' , 'zone' , 'status' , 'failcount' , 'method' , 'name' ) . skip ( start ) . limit ( limit ) . run ( rdb ) for mon in monitors : mon [ 'starttime' ] = datetime . datetime . fromtimestamp ( mon [ 'starttime' ] ) . strftime ( '%Y-%m-%d %H:%M:%S' ) retdata . append ( mon ) elif method == "detail-history" : retdata = [ ] mon = r . table ( 'history' ) . get ( hid ) . pluck ( 'starttime' , 'cid' , 'zone' , 'status' , 'failcount' , 'method' , 'name' ) . run ( rdb ) mon [ 'reactions' ] = [ ] reactions = r . table ( 'history' ) . filter ( ( r . row [ 'cid' ] == self . cid ) & ( r . row [ 'starttime' ] == mon [ 'starttime' ] ) & ( r . row [ 'zone' ] == mon [ 'zone' ] ) & ( r . row [ 'type' ] == "reaction" ) ) . pluck ( 'name' , 'rstatus' , 'time' , 'starttime' ) . run ( rdb ) for react in reactions : react [ 'starttime' ] = datetime . datetime . fromtimestamp ( react [ 'starttime' ] ) . strftime ( '%Y-%m-%d %H:%M:%S' ) react [ 'time' ] = datetime . datetime . fromtimestamp ( react [ 'time' ] ) . strftime ( '%Y-%m-%d %H:%M:%S' ) mon [ 'reactions' ] . append ( react ) mon [ 'starttime' ] = datetime . datetime . fromtimestamp ( mon [ 'starttime' ] ) . strftime ( '%Y-%m-%d %H:%M:%S' ) retdata . append ( mon ) elif method == "count" : retdata = r . table ( 'history' ) . filter ( ( r . row [ 'cid' ] == self . cid ) & ( r . row [ 'starttime' ] >= time ) & ( r . row [ 'type' ] == "monitor" ) ) . count ( ) . run ( rdb ) return retdata