Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Refactor search filter #745

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

schoettl
Copy link
Collaborator

@schoettl schoettl commented Nov 6, 2021

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

const clockFilters = searchFilterExpr
.filter((f) => f.type === 'field')
.filter((f) => f.field.type === 'clock');
// TODO these depend on clockFilters which is now in isMatch() ...
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will take me a time, too, to understand all those filters again. I moved the clock filter added by you, @tarnung, to isMatch – but I don't understand yet what your other lines do and how we can refactor that...

It's late ^^ I just wanted to make a note for now.

@tarnung
Copy link
Collaborator

tarnung commented Nov 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants