Skip to content

Commit

Permalink
Suite state now only reports last 6 tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed Jun 27, 2016
1 parent d0af55f commit 3ed3ae7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
30 changes: 16 additions & 14 deletions lib/cylc/gui/gscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ def _on_query_tooltip(self, widget, x, y, kbd_ctx, tooltip):
state = info[cell_index].strip().split(' ')[0]
point_string = model.get(iter_, 5)[0]
tasks = self.updater.get_last_n_tasks(
suite, host, state, point_string, 5) # Last 5 tasks.
suite, host, state, point_string)
tooltip.set_markup('<b>{state}</b>\n{tasks}'.format(
state=state,
tasks='\n'.join(tasks))
Expand Down Expand Up @@ -981,31 +981,33 @@ def clear_stopped_suites(self):
self.stopped_hosts_suites_info.clear()
gobject.idle_add(self.update)

def get_last_n_tasks(self, suite, host, task_state, point_string, n):
def get_last_n_tasks(self, suite, host, task_state, point_string):
"""Returns a list of the last 'n' tasks with the provided state for
the provided suite."""
# Get list of tasks for the provided state or return an error msg.
if suite + host not in self.tasks_by_state:
return ['<i>Could not get info, try refreshing the scanner.</i>']
tasks = self.tasks_by_state[suite + host][task_state]
tasks = list(self.tasks_by_state[suite + host][task_state])
if tasks is False:
return ['<i>Cannot connect to suite.</i>']

# Append "And x more" to list if required.
temp = [(dt, tn, ps) for (dt, tn, ps) in tasks if dt is None]
suffix = []
if temp:
tasks.remove(temp[0])
if not point_string:
suffix.append('<i>And %s more</i>' % (temp[0][1],))

# Filter by point string if provided.
if point_string:
ret = [(last_timestamp, task_name + '.' + p_string) for
(last_timestamp, task_name, p_string) in tasks if
ret = [task_name + '.' + p_string for
(_, task_name, p_string) in tasks if
p_string == point_string]
else:
ret = [(task[0], task[1] + '.' + task[2]) for task in tasks]

# Return only the n youngest items.
ret.sort(reverse=True)
if len(ret) - n == 1:
n += 1
suffix = [] if len(ret) <= n else [
'<i>And %d more</i>' % (len(ret) - n,)]
return [task[1] for task in ret[0:n]] + suffix
ret = [task[1] + '.' + task[2] for task in tasks]

return ret + suffix

def update(self):
"""Update the Applet."""
Expand Down
9 changes: 8 additions & 1 deletion lib/cylc/network/suite_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,14 @@ def get_tasks_by_state(self):
self.task_summary[task][time_string]):
time_strings.append(self.task_summary[task][time_string])
task_name, point_string = task.rsplit('.', 1)
ret[state].append((max(time_strings), task_name, point_string))
ret[state].append((max(time_strings), task_name, point_string,))
for state in ret:
ret[state].sort(reverse=True)
if len(ret[state]) < 7:
ret[state] = ret[state][0:6]
else:
ret[state] = ret[state][0:5] + [
(None, len(ret[state]) - 6, None,)]
return ret

def get_summary_update_time(self):
Expand Down

0 comments on commit 3ed3ae7

Please sign in to comment.