TACTIC Open Source
how to filter task that nolonger have parents? - Printable Version

+- TACTIC Open Source (http://forum.southpawtech.com)
+-- Forum: TACTIC Open Source (http://forum.southpawtech.com/forumdisplay.php?fid=3)
+--- Forum: TACTIC Discussion (http://forum.southpawtech.com/forumdisplay.php?fid=4)
+--- Thread: how to filter task that nolonger have parents? (/showthread.php?tid=106)



how to filter task that nolonger have parents? - EricTsuei - 04-30-2020

how to filter task that no longer have parents?
can't use filter > parent  code is empty


for example, create a shot, then create tasks for this shot, then delete this shot, but not delete this shot's tasks.
how to filter these task that parents have been deleted?


RE: how to filter task that nolonger have parents? - remkonoteboom - 04-30-2020

That's a tricky one to do in pure expression language (or pure SQL even) because it violates data integrity.  Technically, it would be argued that some trigger should cascade any foreign key relationships  and delete them or at least clear them.  Then you could easily search for a NULL value.

If they have already been deleted, then I am not sure how to do this without Python and this would be pretty heavy if you have a lot of tasks.


Code:
shot_codes = Search.eval("@GET(vfx/shot.code)")
shot_codes = set(shot_codes) # sets are faster to look up

search  = Search("sthpw/task")
search.add_filter("search_type", "vfx/shot%", op="like") # to reduce task to just shot tasks
tasks = search.get_sobjects()
for task in tasks:
  if task.get("search_code") not in shot_codes:
      print("Not found: ", task.get_code() )