KM vs AppleScript Running – Calendar Check Slow

Hi Guys,

I have a question on KM and AppleScript. I know there have been previous threads (e.g here), but they were all on only similar topics, hence I would like to open a new topic.

What I want to do is to find in one of my calendars all events that are marked with a "□". All my open events or deadline are marked with a □. I manually change them to ✓ once I have completed them. For me it is good to know if I missed any, or also what are the next To-Dos for the next 7 days.

Hence I build a script in KM that basically runs an AppleScript and afterwards I convert the results with KM in a more readable format.

The AppleScript is checking for 3 combined factors. Now to my issue:
If I run the Script in AppleScript, it takes 6 seconds to show me the results.
If I run the Script in KM, it takes more than a minute, sometimes longer.

For clarifications, the runtime is the same in KM even if I disable to later "search & replace".

Is there any way to speed this procedure up by editing the script or any other way? Happy to hear your ideas.

Here is my script, maybe it is also useful to some of you:

property calendarName : "Private" -- name of the specific calendar 
property searchTerm : "□" -- or whatever
--------------------------------------------------------
set endDate to (current date) - (7 * days)

tell application "Calendar"
   tell calendar calendarName
      
      set SummaryPrivate to every event's summary whose ¬
         start date is not greater than or equal to (current date) ¬
         and ¬
         end date is not less than endDate ¬
         and ¬
         summary starts with searchTerm
   end tell
   
   set SummaryCheck to SummaryPrivate & " END "	
end tell

return SummaryCheck