def job_dashboard(project_id): jobs = JobExecution.list_jobs(project_id) unique_spiders = set() for job in jobs['COMPLETED']: instance = job['job_instance'] unique_spiders.add(instance.get('spider_name')) spider_colours = {} for spider_name in unique_spiders: spider_id, old_items_count = JobExecution.get_last_execution_by_spider(spider_name, project_id) if not old_items_count: spider_colours[spider_name] = { 'colour': None, 'spider_id': spider_id } continue last_items_count = old_items_count.pop(0) (min_items_count, average_items_count, max_items_count) = _compute_item_stats(old_items_count, last_items_count) if 0 <= last_items_count <= min_items_count: colour = 'danger' elif min_items_count < last_items_count <= max_items_count: colour = 'success' else: colour = 'warning' spider_colours[spider_name] = { 'colour': colour, 'spider_id': spider_id } return render_template("job_dashboard.html", job_status=jobs, spider_colours=spider_colours, bit_enabled=config.BACK_IN_TIME_ENABLED)
def job_dashboard(project_id): return render_template("job_dashboard.html", job_status=JobExecution.list_jobs(project_id))
def get(self, project_id): return JobExecution.list_jobs(project_id)