organice icon indicating copy to clipboard operation
organice copied to clipboard

WIP Refactor search filter

Open schoettl opened this issue 2 years ago • 1 comments

The filter for clock times should be in isMatch ...

schoettl avatar Nov 06 '21 23:11 schoettl

The main issue is that the "clock" search criterion depends on information that is spread out over multiple headers because "logged time" is a recursive property that gets inherited by and added up in parent headers. It is therefore necessary to do the calculations of "logged time" in a place where we have access to all headers - which isMatch hasn't. The result of these calculations are saved as "header.totalFilteredTimeLogged" and "header.totalFilteredTimeLoggedRecursive". The actual search function is just checking if "totalFilteredTimeLoggedRecursive" is not zero.

  1. checking if not zero could be pushed to "isMatch"
  2. calculation of "totalFilteredTimeLoggedRecursive " zero could be pushed into "isMatch" if the returned function gets all headers with "totalFilteredTimeLogged" precalculated as a second argument
  3. calculation of "totalFilteredTimeLogged" can only be pushed into "isMatch" if we calculate it for the header handed to "isMatch" and all its subheaders.

Option one does not offer much gain. Option two depends on if you are willing to allow "isMatch" or the function returned by it access to all searched headers. Option three would probably be the cleanest but some calculations are done multiple times especially for deeply nested headers.

tarnung avatar Nov 07 '21 10:11 tarnung