Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing querying of historic job data #511

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Change jobs query to use list of tasks
  • Loading branch information
JAllen42 committed Oct 3, 2023
commit b779063710647c3ef7b51cc44a3f72fbdc7be3c0
20 changes: 12 additions & 8 deletions cylc/uiserver/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ async def list_jobs(args):
)
with CylcWorkflowDAO(db_file, is_public=True) as dao:
conn = dao.connect()
jobs.extend(make_jobs_query(conn, workflow, args.get('task_name')))
jobs.extend(make_jobs_query(conn, workflow, args.get('tasks')))
return jobs


Expand Down Expand Up @@ -499,16 +499,19 @@ def make_query(conn, workflow):
return tasks


def make_jobs_query(conn, workflow, task):
def make_jobs_query(conn, workflow, tasks):

# TODO: support all arguments including states
# https://github.com/cylc/cylc-uiserver/issues/440
jobs = []
# Make this more secure
if task:
snippet = f" AND name = '{task}'"

# Create sql snippet used to limit which tasks are returned by query
if tasks:
where_clauses = "' OR name = '".join(tasks)
where_clauses = f" AND (name = '{where_clauses}')"
else:
snippet = ''
where_clauses = ''

for row in conn.execute(f'''
SELECT
name,
Expand All @@ -526,7 +529,8 @@ def make_jobs_query(conn, workflow, task):
FROM
task_jobs
WHERE
run_status = 0{snippet};
run_status = 0
{where_clauses};
'''):
jobs.append({
'id': workflow.duplicate(
Expand Down Expand Up @@ -642,7 +646,7 @@ class LogFiles(graphene.ObjectType):
mindepth=graphene.Int(default_value=-1),
maxdepth=graphene.Int(default_value=-1),
sort=SortArgs(default_value=None),
task_name=graphene.String()
tasks=graphene.List(ID, default_value=[])
)


Expand Down