Help with a filter - not the behaviour I wanted from limit operator

Hi, I wondered if anyone could help me with the following filter issue?

Background: I wrote a plugin to flag knowledge based tiddlers which are due for a review (read through) based on time interval which is set by the user for each tiddler - so I might want to review a tiddler every 100 days. It’s just a way of making sure that valuable chunks of knowledge stay fresh.

Here is the filter - it is used when I have got behind in my reviewing of tiddlers and have a back log, it just means I set say 200 tiddlers at a time as if I had actually looked at them just so I can clear the backlog - I store review period as a number of days but for simplicity with the days operator it is stored as a negative integer.

<$list filter="[all[tiddlers]!is[system]has:field[last-reviewed3]!days:last-reviewed3{!!interval3}limit[200]]">

So first I test if a tiddler is one that is in the "review scheme’ by testing for the field ‘last-reviewed’ then I test if the tiddler is overdue using the ‘days’ operator and finally in this example I indicate that I only want to remove 200 tiddlers from the backlog.

The problem is that fewer than 200 tiddlers end up being reset, I suspect that this is because the limit operator is doing it’s job earlier in the filter, almost as if 200 tiddlers are being selected and then the other criteria are being applied.

I thought filters were evaluated left to right?

I could choose just to remove the limit filter but I would like to better understand the situation.

Filters are executed from left to right.

You could try this filter: <$list filter="[all[tiddlers]!is[system]has:field[last-reviewed3]!days:last-reviewed3{!!interval3}] +[limit[200]]">

Thanks, unfortunately it seems to have the same behaviour, almost as if the limit operator is being executed out of sequence. When I removed the limit operator all overdue tiddlers were processed as expected - there were no overdue tiddlers after the operation - so it has the correct behaviour, for my own use I may decide simply to do without this refinement it was not really important, I just wanted to see if I was missing some piece of knowledge.

Is it conceivable that the limit operator does not observe the left to right rule I wonder?

Of course there might be something wrong with my code but I would be a bit surprised because of the behaviour when I removed the limit operator, I would expect inconsistencies there as well but the behaviour was as expected.

does it work with a lesser number eg limit[2] ?

what is the value of

<$list filter="[all[tiddlers]!is[system]has:field[last-reviewed3]!days:last-reviewed3{!!interval3}count[]]">

Hi Buggyj,

I don’t have the number for the filter for a count as you suggested it…

<$list filter="[all[tiddlers]!is[system]has:field[last-reviewed3]!days:last-reviewed3{!!interval3}count[]]">

but my plugin already features information on the number of tiddlers overdue for a review which does the same job…it is the values reported by the following filter that I use to measure how many tiddlers actually did get updated by comparing the before and after values which indicates that fewer tiddlers were updated than the limit value.

There are <$count filter= "[all[tiddlers]!is[system]has:field[last-reviewed3]] :filter[!days:last-reviewed3{!!interval3}]"/> Overdue tiddlers'

And at the time I wrote the post and was revisiting this issue the count was around 800, I had quite a backlog to deal with!

Yes I have tried experimentally smaller limits, I cannot remember if I tried limit[2] but I have tried values
such as limit[30] whenever I revisit this problem, every so often I look at it and poke around but so far nothing has worked.

So basically the core of my code to clear a backlog is like this…(I didn’t include the outer layers of out the code which is for buttons)

<$list filter="[all[tiddlers]!is[system]has:field[last-reviewed3]!days:last-reviewed3{!!interval3}limit[200]"> <$action-setfield last-reviewed3=<<now "[UTC]YYYY0MM0DD0hh0mm0ss0XXX">> $timestamp="no"/> </$list>

So setting the last-reviewed3 field to today’s date effectively clears that tiddler from the backlog.

Inspired by your suggestion to add count[] for investigation I might try a filter that ends in…

<$list filter="[all[tiddlers]!is[system]has:field[last-reviewed3]!days:last-reviewed3{!!interval3}limit[20]count[]]">

The behaviour I expect is that the first 20 tiddlers that are overdue as defined by the first parts of the filter will be counted and so count should be 20 as long as there are more than 20 overdue tiddlers in total.

If on the other hand count is less than 20 then that suggests to me that the limit filter is being applied prematurely and so the overdue tiddlers are selected from a list of only 20 candidates.

In some ways I have moved on from the problem as I have simply removed the limit feature altogether but it is interesting what is going on here, I do think there is a good possibility that limit does not play nicely with the usual Left to Right rules.

you could try using a counter to see the number

$list filter="[all[tiddlers]!is[system]limit[200]]" counter="z"> <<z>> </$list>