Advice on rule or agent which targets thousands of objects


(George Wyner) #1

I am currently using a single tbx document to hold my project notes and to do lists. By default, most of my notes wind up with prototype Task, so there are thousands of instances of that prototype.

I have a few bits of automation I want to apply across these tasks.

For all tasks, I want to check to see if the $Urgent attribute has changed and update border accordingly.

For those tasks with $Repeating true (maybe 5-10% of total), I have more complex logic that examines various dates and under some circumstances changes the container for an object.

Currently I have all this logic stored in the $Rule of the prototype, so there are thousands of rules, all of them with all the logic.

I am experimenting with assigning this logic to two agents.

A “tasks” agent would just handle the $Urgent formatting and a couple of other minor attribute changes (set $IsTask = true and maybe one or two other things). The query would return all notes with prototype Task.

A “repeating” agent would query all notes with $Repeating & $Prototype == Task and would run the more elaborate logic on those.

Does that seem like a reasonable approach from stability and performance point of view? Thousands of rules are replaced by two agents. One agent only needs to act on a few hundred notes or less.

Is there an advantage to having the Repeating agent look in the tasks agent instead of repeating the test of Prototype?

Is there any reason to leave some of this as a rule?

Thanks for any advice!

George


(eastgate) #2

Why not have a prototype for RepeatingTask, which could inherit from Task but add some additional rules that only apply to repeating tasks? That saves some work, and might also make some of your agents cleaner.

But yes, it’s always good to replace a lot of rules with a few agents.