11-30-2020, 06:16 PM
Hey all, been playing around with custom layouts, trying some of the graph and chart tools from the VFX template in v4.5
I can get stats for the task I'm looking for but regardless of which task I have in the code, the graph will always display the status from unrelated tasks.
Example, the below code will show me the statuses of ANIMATION, COMPOSITING or whatever is in this line: filters.append(['pipeline_code','development/ANIMATION'])
but will also include statuses from any task that has the same status in any pipeline in the project.
So it includes "Ready to Start" and "Assignment" from Rigging or Design in the total for example.
The images below should only be ANIMATION according to the script but there are no tasks set to Assignment or Ready to Start in the ANIMATION pipe.
Two questions: How do I prevent these statuses from other tasks being added to the totals and is it possible to generate this graph based on input from a search in the advanced search menu?
I can get stats for the task I'm looking for but regardless of which task I have in the code, the graph will always display the status from unrelated tasks.
Example, the below code will show me the statuses of ANIMATION, COMPOSITING or whatever is in this line: filters.append(['pipeline_code','development/ANIMATION'])
but will also include statuses from any task that has the same status in any pipeline in the project.
So it includes "Ready to Start" and "Assignment" from Rigging or Design in the total for example.
The images below should only be ANIMATION according to the script but there are no tasks set to Assignment or Ready to Start in the ANIMATION pipe.
Two questions: How do I prevent these statuses from other tasks being added to the totals and is it possible to generate this graph based on input from a search in the advanced search menu?
Code:
<div class="spt_top">
<%
my_tasks = kwargs.get("my_tasks")
if my_tasks == 'true':
total_expr = "@COUNT(sthpw/task['project_code', $PROJECT]['assigned', $LOGIN])"
else:
total_expr = "@COUNT(sthpw/task['project_code', $PROJECT])"
HEIGHT = 500
THICKNESS = 40
total_tasks = server.eval(total_expr)
process_list_expr = "@UNIQUE(@GET(sthpw/task['project_code', $PROJECT].status))"
process_names = server.eval(process_list_expr)
filters = []
filters.append(['pipeline_code','development/ANIMATION'])
order_bys = ['sort_order asc']
process_list = server.query("config/process", filters=filters, order_bys=order_bys)
bar_width = 100.0 / len(process_list)
context.write("<table width='100%%' height='%dpx' cellspacing='0px'>" %(HEIGHT) )
context.write("<tr class='chart_inner'>")
drawn_processes = []
for process in process_list:
status = process.get("process")
if status not in process_names:
continue
if status in drawn_processes:
continue
drawn_processes.append(status)
color = process.get("color")
if my_tasks == 'true':
count_expr = "@COUNT(sthpw/task['project_code', $PROJECT]['status', '%s']['assigned', $LOGIN])" %(status)
else:
count_expr = "@COUNT(sthpw/task['project_code', $PROJECT]['status', '%s'])" %(status)
count = server.eval(count_expr)
if count == 0:
bar_height = 1
else:
bar_height = (HEIGHT - 1) * ((count*1.0) / total_tasks)
bar_div = "<div>%s</div>" %count
bar_div += "<div class='chart_bar' style='height:%spx; background:%s;'> </div>" %(bar_height, color)
td = "<td valign='bottom' style='text-align:center;' width='%s%%'>%s</td>" %(bar_width, bar_div)
context.write(td)
context.write("</tr>")
context.write("<tr>")
drawn_processes = []
for process in process_list:
status = process.get("process")
if status not in process_names:
continue
if status in drawn_processes:
continue
drawn_processes.append(status)
title = "Show all tasks [%s]" %status
status_link = "<a style='cursor:hand;' title='%s'>%s</a>" %(title, status)
label_div = "<div class='spt_status' spt_status='%s' style='text-align:center; font-weight:bold'>%s</div>" %(status, status_link)
td = "<td valign='top'>%s</td>" %label_div
context.write(td)
context.write("</tr>")
context.write("</table>")
%>
</div>