Filter Question - using a tiddler field (integer value) decremented by 1

Hi, I am a bit stuck…

I use the following to alert me to tiddlers that require a review, there are two fields in tiddlers in the ‘review pool’ - the date last reviewed named “last-reviewed3” and the review interval expressed in days but for convenience stored as a negative value named “interval3”, so -30 would mean review every 30 days.

{{{[all[tiddlers]!is[system]has:field[last-reviewed3]]
      :filter[!days:last-reviewed3{!!interval3}]
      +[sort[last-reviewed3]limit[10]]}}}

If there was nothing to review today I might want to look at tiddlers that will require review tomorrow - so if the tiddler field interval3 was set to -30 then I would like to run the filter a second time with a value of -31 but I don’t want to change the actual value in the tiddler field.

My problem is to be able to insert a value in place of interval3 in the second filter run (ie -30 the first run and -31 in the second run). I am not having much luck working out how to add the arithmetic step in the filter.

Thanks…

I’m not sure how you intend to run this twice, but for your second run, could you wrap that expression in a <$let> and change {!!interval3} to a variable?

<$let interval={{{ [{!!interval3}subtract[1]] }}} >

{{{[all[tiddlers]!is[system]has:field[last-reviewed3]]
      :filter[!days:last-reviewed3<interval>]
      +[sort[last-reviewed3]limit[10]]}}}

</$let>

Hi Scott,

Sorry my bad, by run twice I mean the filter will simply appear a second time in the same tiddler (actually a sidebar tab) - it simply dumps a list of ten tiddlers that require review today and a second version of that filter modified for the “tomorrow” case would dump a second list of tiddlers. So two versions of the code I posted - one after the other, the second one with a modification to give tomorrows results rather than todays.

Thanks for the suggestion, but interval3 is a field in the current tiddler that is being processed in the filter run and so it is changing value as the filter works its way through the tiddlers. That’s the thing that is stumping me I haven’t found a way of taking the value of a field and decrementing it within the filter run.

Yes, I read far too quickly.

I assume days is a custom operator, with one possible suffix of last-reviewed3. Can you add another suffix (last-reviewed3-1?) that subtracts one from its operand and then calls the existing last-reviewed3 functionality with this new value?

Hi @jonnie45

You can define a function to compute the new value and use it in place of the field, like this:

<!-- at the top of tiddler text: -->
\function minus.one() [{!!interval3}add[-1]]

<!-- and then: -->

{{{[all[tiddlers]!is[system]has:field[last-reviewed3]]
      :filter[!days:last-reviewed3<minus.one>]
      +[sort[last-reviewed3]limit[10]]}}}

Hope this helps,

Fred

1 Like

Hi Scott, thanks…no days is part of the default operator set of tiddlywiki its not a custom operator, the suffix is the name of the field (it should be a field containing a date) to be used in the current tiddler - if the suffix is not supplied then the date operator assumes we want to use the modified field.

1 Like