Hello all!
I am trying to adapt the script Jesse provided in the Outline Paths release topic to the journal script from the Bike guide.
I have modified the outline path to look for child tasks from the previous sibling of the “today” row, and transfer their top level row into the newest today node. However, the only way I can get the top level row of any descendant that contains a subtask is by hard coding the value for @level
.
Here’s a sample outline path:
//@id matches "2023_11_08"/task not @done union //@id matches "2023_11_08"/descendant:: not task/task not @done/ancestor:: @level matches 4
I tried using a value expression, but (//@id matches "2023_11_08"/@level)
didn’t evaluate to 4.
Did I misinterpret the use of value expressions, or is there another way I could write this path to achieve my goal? I can also attach a sample journal file if necessary.
And if anyone wants to see / use the full script in its current state please expand this triangle
set yearName to do shell script "date +'%Y'"
set yearId to do shell script "date +'%Y'" & "/00/00"
set monthName to do shell script "date +'%B'"
set monthId to do shell script "date +'%Y_%m'" & "/00"
set dayName to do shell script "date +'%a, %B %e, %Y'"
set dayId to do shell script "date +'%Y_%m_%d'"
tell application "Bike"
tell front document
set y to my getOrMake(yearId, yearName, root row)
set m to my getOrMake(monthId, monthName, y)
set d to my getOrMake(dayId, dayName, m)
try
set yesterdayId to id of prev sibling row of d
on error
select at make row at back of rows of d
return
end try
set notDonePath to "//@id matches" & "\"" & yesterdayId & "\"" & "/task not @done union //@id matches " & "\"" & yesterdayId & "\"" & "/descendant:: not task/task not @done/ancestor:: @level matches 4"
set notDoneTasks to query outline path notDonePath
repeat with notDoneTask in notDoneTasks
move notDoneTask to d
end repeat
select at make row at back of rows of d
end tell
end tell
to getOrMake(getId, getName, rowContainer)
using terms from application "Bike"
tell container document of rowContainer
if exists row id getId then
return row id getId
else
tell rowContainer
return make row with properties {id:getId, name:getName, type:heading}
end tell
end if
end tell
end using terms from
end getOrMake