Tinderbox Training Video 27 - TBX - Deconstructing Daily Journal Date Descendants Management

Tinderbox Training Video - TBX - Deconstructing Daily Journal Date Descendants Management

Level Intermediate
Published Date 1/31/21
Tags Tinderbox, aTbRef, 4Cs of Knowledge Exchange, Conditional Expression, Group Designator, Descendants Designator, Collect If Expression, List/Set Dot Operators
Video Length 07:28
Video URL Tinderbox Video - Deconstructing the Daily Journal Date Descendants and Color Change Logic - YouTube
Example File TBX - L Managing Daily-Journal-Time-Projects-FINAL30JAN21.zip (121.5 KB)
Contains sample TBX file and commented project & milestone rules action code.
Revision 2, Jan. 31, 2021
TBX Version 8.9
Related Lessons Tinderbox Training Video - Daily Journal Time Tracking Project Management Part 1
Instructor Michael Becker

In this lesson, I deconstruct the method for assigning a project, initiative, or milestone note’s $StartDate and $DueDate’s value by pulling the dates from the note’s descendants. To accomplish this, I’m using the action code in the note’s Rule, specifically,

  • $ChildCount system attribute
  • Conditional expression
  • A group designator, descendants
  • collect_if operators
  • two dot operators, .in and .max

REMEMBER:

1. Defining a note, A note is a note, the only thing that makes a note a project, initiative, or milestone versus some other note is the prototype I’ve assigned it.

2. There is often more than one way to accomplish a task in Tinderbox, the technique you choose will depend on a number of factors, including how often you want to perform an operation (e.g. maybe you don’t need automation if you’re not going to do it that often), will you want the operation to support other tasks (e.g. cache variables for you), and how big your file might get, aka do you need to employ one or more optimization strategies so that your file works as efficiently as possible as the number of notes it contains grows.

3. Incremental formalization is your friend, don’t be afraid of incremental formalization, in fact, one of the major benefits of Tinderbox is that it helps you think and formalize your process as you go along. Once you find a better way to do something or find the way you’re doing it now no longer works in your current context, you can always change it.

Deconstructing the Daily Journal Date Descendants

Reference Material

Commented Project & Initiative Prototype Rule Action Code

The following is the milestone Rule action code for the following TBX demo file Tinderbox Training Video 26 - Daily Journal Time Tracking Project Management Part 1. Note, I’m using a Rule, vs. an Edict, because I want it the actions to take effect as soon as possible.

$TotalCost=sum(descendants,$Cost);
$TotalEffort=sum(descendants,$EffortDay);
$TotalTime=sum(descendants,$Time);
if($ChildCount>0){
   $StartDate=collect_if(descendants,$StartDate!="never",$StartDate).min;
   $DueDate=collect_if(descendants,$DueDate!="never",$DueDate).max;
};
if(($StartDate=="never"|$DueDate=="never")&$Checked==false){
   if($ColorCaution!=$Color){
     $Color=$ColorCaution;}
   }else{
     if($StartDate>$DueDate){
        if($ColorAlarm!=$Color){
           $Color=$ColorAlarm;}
        }else{
          $Color=;
        }
     }
};
if($Checked==true&$StartDate!="never"&$EndDate=="never"){
      $EndDate="now";
      $Status="Complete";
      $Color="green";
      $Time=interval($StartDate,$EndDate);
   }else{
      if($Checked==true&$StartDate=="never"&$EndDate=="never"){
         $EndDate=date("now");
         $Status="Complete";
         $Color="green";
      }
};
if($Checked==true){
   $RuleDisabled=true;
};

EXPLANATION OF ACTION CODE

This code sums the $Cost data, a number attribute, from all the note’s descendants. This is useful to estimate the total costs for my projects.

$TotalCost=sum(descendants,$Cost);

This code sums the $EffortDay data, a number attribute, from all the note’s descendants. This is useful to estimate the total estimated effort in days for my projects.

$TotalEffort=sum(descendants,$EffortDay);

This code sums the $Time spent on each descendant in a project. This is useful to estimate the total actual time spend on a project.

$TotalTime=sum(descendants,$Time);

The following action code is used to assess the date of the milestone descendants. It first tests to see if a note has the milestone prototype and if it has children. If this comes back true, then the action code evaluates the note’s descendants. It grabs the earliest date amongst the notes that have a $StartDate and sets the milestone $StartDate with that value; then it grabs the latest date amongst the notes that have a $DueDate and sets the milestone $DueDate with that value.

if($ChildCount>0){
   $StartDate=collect_if(descendants,$StartDate!="never",$StartDate).min;
   $DueDate=collect_if(descendants,$DueDate!="never",$DueDate).max;
};

Note, when I first tried this I used the following code:

if($ChildCount>0&any(children,$StartDate!="never")){
   $StartDate=date(collect_if(children,$StartDate,$StartDate).sort.at(0));
   $DueDate=date(collect_if(children,$DueDate,$DueDate).sort.at(-1));
};

This worked, just like the above code; however, it is not optimal for file performance. This has Tinderbox create a list of every child note, sort them, and then pick the youngest or the latest dates. It works, but all the extra steps provide no value when all I want are the min and max dates. There is no need for extra processing cycles. Also, I realized at one point that children might have children, so I adopted the descendant group designator over the children group designator.

The following code is used to assess whether the $StartDate & $EndDate of a note does not have a value, if the $StartDate is after the $DueDate, and if $Checked is false. If these cases, once tested, return a true or false, depending on the context, a note’s color is changed.

The color change has visual semantic value. It lets me know if I should take manual action on a note or not.

This test will only run on notes when $Checked is false.

I have the rule set notes to yellow that are missing dates and notes to red whose $StartDate falls after the $DueDate.

The first condition checks if either of the dates has a value and if $Checked is false. If any of either of the date conditions come back true, the notes should be yellow. If the note is $Checked, the rest of the rule is skipped.

The $ColorCaution and $ColorAlarm attributes are used for performance and optimization. Tinderbox will redraw the views each time a note changes color. To this end, I only want to change the color if necessary. The action code will first check if the color is already yellow by testing it against the $ColorCaution attribute, whose value is “yellow”. If the note is already yellow, i.e. the test comes back true, then the color will not change, saving Tinderbox processing cycles. If it comes back false, it will change the color to yellow.

If the dates have value, Tinderbox will check if the $StartDate is after the $EndDate, if it is, it will change the color to red. Like above, I’m using a cached variable, $ColorAlarm, as a process optimization step.

If the above conditions fail, then the note color is set to gray, which signals to me all the dates are aligned, and the note is still active and should be managed.

if(($StartDate=="never"|$DueDate=="never")&$Checked==false){
   if($ColorCaution!=$Color){
     $Color=$ColorCaution;}
   }else{
     if($StartDate>$DueDate){
        if($ColorAlarm!=$Color){
           $Color=$ColorAlarm;}
        }else{
          $Color=;
        }
     }
};

This action code helps me signal that a milestone is complete, i.e. change the color and adjust attribute values when $Checked is true.

The code first test if $Checked is true and if the $StartDate has a value and if $EndDate does note If these conditions are true, then the $EndDate is set to the time current time, the $Status attribute is set to complete, the color is changed to green, and the interval time between the $StartDate and $EndDate is calculated with the result placed in $Time. The $Time value is be useful as you can run reports on how much time was spent on different activities or on the overall milestone.

If both dates are never, then the $EndDate is set to the current date, the note is turned green, the $Status is set to Complete. The interval time is not calculated.

if($Checked==true&$StartDate!="never"&$EndDate=="never"){
      $EndDate="now";
      $Status="Complete";
      $Color="green";
      $Time=interval($StartDate,$EndDate);
   }else{
      if($Checked==true&$StartDate=="never"&$EndDate=="never"){
         $EndDate=date("now");
         $Status="Complete";
         $Color="green";
      }
};

For optimization purposes, so that the action code of a complete task is not run, I have the action code turn disable the running of a rule if the note is checked.

if($Checked==true){
   $RuleDisabled=true;
};

Author Attribution: Michael J. Becker, Identity Praxis, Inc. (C) 2020. https://www.linkedin.com/in/selfsovereignidentityprivacyshaman/

Commented Milestone Prototype Rule Action Code

The following is the milestone Rule action code for the following TBX demo file Tinderbox Training Video 26 - Daily Journal Time Tracking Project Management Part 1. Note, I’m using a Rule, vs. an Edict, because I want it the actions to take effect as soon as possible.

if($Prototype=="pMilestone"&$ChildCount>0){
   $StartDate=collect_if(descendants,$StartDate!="never",$StartDate).min;
   $DueDate=collect_if(descendants,$DueDate!="never",$DueDate).max;
};
if(($StartDate=="never"|$DueDate=="never")&$Checked==false){
   if($ColorCaution!=$Color){
     $Color=$ColorCaution;}
   }else{
     if($StartDate>$DueDate){
        if($ColorAlarm!=$Color){
           $
           Color=$ColorAlarm;}
        }else{
          $Color=;
        }
     }
};
if($Checked==true&$StartDate!="never"&$EndDate=="never"){
      $EndDate="now";
      $Status="Complete";
      $Color="green";
      $Time=interval($StartDate,$EndDate);
   }else{
      if($Checked==true&$StartDate=="never"&$EndDate=="never"){
         $EndDate=date("now");
         $Status="Complete";
         $Color="green";
      }
};
if($Checked==true){
   $RuleDisabled=true;
};

EXPLANATION OF ACTION CODE

The following action code is used to assess the date of the milestone descendants. It first tests to see if a note has the milestone prototype and if it has children. If this comes back true, then the action code evaluates the note’s descendants. It grabs the earliest date amongst the notes that have a $StartDate and sets the milestone $StartDate with that value; then it grabs the latest date amongst the notes that have a $DueDate and sets the milestone $DueDate with that value.

if($Prototype=="pMilestone"&$ChildCount>0){
   $StartDate=collect_if(descendants,$StartDate!="never",$StartDate).min;
   $DueDate=collect_if(descendants,$DueDate!="never",$DueDate).max;
};

Note, when I first tried this I used the following code:

if($ChildCount>0&any(children,$StartDate!="never")){
   $StartDate=date(collect_if(children,$StartDate,$StartDate).sort.at(0));
   $DueDate=date(collect_if(children,$DueDate,$DueDate).sort.at(-1));
};

This worked, just like the above code; however, it is not optimal for file performance. This has Tinderbox create a list of every child note, sort them, and then pick the youngest or the latest dates. It works, but all the extra steps provide no value when all I want are the min and max dates. There is no need for extra processing cycles. Also, I realized at one point that children might have children, so I adopted the descendant group designator over the children group designator.

The following code is used to assess whether the $StartDate & $EndDate of a note does not have a value, if the $StartDate is after the $DueDate, and if $Checked is false. If these cases, once tested, return a true or false, depending on the context, a note’s color is changed.

The color change has visual semantic value. It lets me know if I should take manual action on a note or not.

This test will only run on notes when $Checked is false.

I have the rule set notes to yellow that are missing dates and notes to red whose $StartDate falls after the $DueDate.

The first condition checks if either of the dates has a value and if $Checked is false. If any of either of the date conditions come back true, the notes should be yellow. If the note is $Checked, the rest of the rule is skipped.

The $ColorCaution and $ColorAlarm attributes are used for performance and optimization. Tinderbox will redraw the views each time a note changes color. To this end, I only want to change the color if necessary. The action code will first check if the color is already yellow by testing it against the $ColorCaution attribute, whose value is “yellow”. If the note is already yellow, i.e. the test comes back true, then the color will not change, saving Tinderbox processing cycles. If it comes back false, it will change the color to yellow.

If the dates have value, Tinderbox will check if the $StartDate is after the $EndDate, if it is, it will change the color to red. Like above, I’m using a cached variable, $ColorAlarm, as a process optimization step.

If the above conditions fail, then the note color is set to gray, which signals to me all the dates are aligned, and the note is still active and should be managed.

if(($StartDate=="never"|$DueDate=="never")&$Checked==false){
   if($ColorCaution!=$Color){
     $Color=$ColorCaution;}
   }else{
     if($StartDate>$DueDate){
        if($ColorAlarm!=$Color){
           $
           Color=$ColorAlarm;}
        }else{
          $Color=;
        }
     }
};

This action code helps me signal that a milestone is complete, i.e. change the color and adjust attribute values when $Checked is true.

The code first test if $Checked is true and if the $StartDate has a value and if $EndDate does note If these conditions are true, then the $EndDate is set to the time current time, the $Status attribute is set to complete, the color is changed to green, and the interval time between the $StartDate and $EndDate is calculated with the result placed in $Time. The $Time value is be useful as you can run reports on how much time was spent on different activities or on the overall milestone.

If both dates are never, then the $EndDate is set to the current date, the note is turned green, the $Status is set to Complete. The interval time is not calculated.

if($Checked==true&$StartDate!="never"&$EndDate=="never"){
      $EndDate="now";
      $Status="Complete";
      $Color="green";
      $Time=interval($StartDate,$EndDate);
   }else{
      if($Checked==true&$StartDate=="never"&$EndDate=="never"){
         $EndDate=date("now");
         $Status="Complete";
         $Color="green";
      }
};

<!--For optimization purposes, so that the action code of a complete task is not run, I have the action code turn disable the running of a rule if the note is checked.-->

if($Checked==true){
   $RuleDisabled=true;
};

Author Attribution: Michael J. Becker, Identity Praxis, Inc. (C) 2020. https://www.linkedin.com/in/selfsovereignidentityprivacyshaman/

2 Likes

Big thanks to @mwra for editing the post and teaching me how to make the code presentable.