From 6e8502251b1da83808a48cface0054515b9fbd34 Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Mon, 27 Jun 2016 11:02:12 +0100 Subject: [PATCH] Suite state now only reports last 6 tasks. --- lib/cylc/gui/gscan.py | 30 ++++++++++++++++-------------- lib/cylc/network/suite_state.py | 9 ++++++++- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/cylc/gui/gscan.py b/lib/cylc/gui/gscan.py index a8fb05970ae..6aedcaa287f 100644 --- a/lib/cylc/gui/gscan.py +++ b/lib/cylc/gui/gscan.py @@ -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('{state}\n{tasks}'.format( state=state, tasks='\n'.join(tasks)) @@ -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 ['Could not get info, try refreshing the scanner.'] - tasks = self.tasks_by_state[suite + host][task_state] + tasks = list(self.tasks_by_state[suite + host][task_state]) if tasks is False: return ['Cannot connect to suite.'] + # 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('And %s more' % (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 [ - 'And %d more' % (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.""" diff --git a/lib/cylc/network/suite_state.py b/lib/cylc/network/suite_state.py index 8b157dece89..90da6f1f0c4 100644 --- a/lib/cylc/network/suite_state.py +++ b/lib/cylc/network/suite_state.py @@ -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]) - 5, None,)] return ret def get_summary_update_time(self):