Add get_jids_filter method to pgjsonb

This commit is contained in:
Alex Moore 2017-04-23 23:36:37 -06:00
parent 51af49495b
commit 553aaad105

View File

@ -382,6 +382,30 @@ def get_jids():
return ret
def get_jids_filter(count, filter_find_job=True):
'''
Return a list of all job ids
:param int count: show not more than the count of most recent jobs
:param bool filter_find_jobs: filter out 'saltutil.find_job' jobs
'''
with _get_serv(ret=None, commit=True) as cur:
sql = '''SELECT * FROM (
SELECT DISTINCT jid ,load FROM jids
{0}
ORDER BY jid DESC limit {1}
) tmp
ORDER BY jid;'''
where = '''WHERE 'load' NOT LIKE '%"fun": "saltutil.find_job"%' '''
cur.execute(sql.format(where if filter_find_job else '', count))
data = cur.fetchall()
ret = []
for jid, load in data:
ret.append(salt.utils.jid.format_jid_instance_ext(jid,load))
return ret
def get_minions():
'''
Return a list of minions