Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/backend.py
Show First 20 Lines • Show All 448 Lines • ▼ Show 20 Lines | def delete_archived_tasks(self, task_ids, db=None, cur=None): | ||||
_task_ids = _task_run_ids = [] | _task_ids = _task_run_ids = [] | ||||
for task_id in task_ids: | for task_id in task_ids: | ||||
_task_ids.append(task_id['task_id']) | _task_ids.append(task_id['task_id']) | ||||
_task_run_ids.append(task_id['task_run_id']) | _task_run_ids.append(task_id['task_run_id']) | ||||
cur.execute( | cur.execute( | ||||
"select * from swh_scheduler_delete_archived_tasks(%s, %s)", | "select * from swh_scheduler_delete_archived_tasks(%s, %s)", | ||||
(_task_ids, _task_run_ids)) | (_task_ids, _task_run_ids)) | ||||
task_run_keys = ['id', 'task', 'backend_id', 'scheduled', | |||||
'started', 'ended', 'metadata', 'status', ] | |||||
@db_transaction() | |||||
def get_task_runs(self, task_ids, limit=None, db=None, cur=None): | |||||
"""Search task run for a task id""" | |||||
where = [] | |||||
args = [] | |||||
vlorentz: duplicate (it's funny that `flake8` didn't catch this) | |||||
Done Inline Actionsyep, it's weird... douardda: yep, it's weird... | |||||
if task_ids: | |||||
if isinstance(task_ids, (str, int)): | |||||
where.append('task = %s') | |||||
else: | |||||
where.append('task in %s') | |||||
task_ids = tuple(task_ids) | |||||
args.append(task_ids) | |||||
else: | |||||
return () | |||||
Not Done Inline ActionsWhy a dict? vlorentz: Why a dict? | |||||
Done Inline Actionsindeed, should be an empty list/tuple here. thx douardda: indeed, should be an empty list/tuple here. thx | |||||
query = 'select * from task_run where ' + ' and '.join(where) | |||||
if limit: | |||||
query += ' limit %s :: bigint' | |||||
args.append(limit) | |||||
cur.execute(query, args) | |||||
return cur.fetchall() | |||||
Not Done Inline Actionssame vlorentz: same | |||||
Not Done Inline ActionsRename to get_task_runs_from_backend? vlorentz: Rename to `get_task_runs_from_backend`? | |||||
Not Done Inline Actionssame vlorentz: same |
duplicate (it's funny that flake8 didn't catch this)