Search code examples
tiddlywikitiddlywiki5

Tiddlywiki 5: filter tiddlers by concatenation of few fields


Trying to adopt this awesome engine as personal task tracker. Having few main types of tiddlers: day, week, sprint, event and task.

All of them have few user fields:

day_since, 
month_since, 
year_since, 
day_due, 
month_due, 
year_due.

For example,

the task will have fields:

day_due="23"
month_due="02"
year_due="2022"

the week will have fields:

day_since="21"
month_since="02"
year_since="2022"
day_due="27"
month_due="02"
year_due="2022"

I do not use date type for purpose - i use xx instead of numbers for some events - like birthdays and holidays to be repeated every year, so i put xx instead of year number etc. I want to filter tasks to show all tasks, fitting into week duration - i have day, month and year both for start and end of the week andd need to build and expression how to shoow all fitting task on the week card.

Got stuck with searching the solution. I use tiddlywiki 5.2.1. Would appreciate any advices.


Solution

  • i've got the solution kindly provided be talk.tiddlywiki.org members:

    here is working code from template:

    <$list filter="[is[current]tag[week]]" >
        <$let 
          week_start={{{ [{!!since_year}] [{!!since_month}] [{!!since_day}]+[join[]] }}}
          week_end={{{ [{!!due_year}] [{!!due_month}] [{!!due_day}]+[join[]] }}}
        >
    
    
        <h2>days:</h2>
        <$list filter="[tag[day]]">
          <h3> {{{ [{!!due_year}] [{!!due_month}] [{!!due_day}]+[join[]] +[compare:number:gteq<week_start>compare:number:lteq<week_end>then<currentTiddler>] }}} </h3>
        </$list>
    
        <h2>corresponding sprint:</h2>
        <$list filter="[tag[sprint]]">
          <$let
            sprint_start={{{ [<currentTiddler>get[since_year]] [<currentTiddler>get[since_month]] [<currentTiddler>get[since_day]] +[join[]] }}}
            sprint_end={{{ [<currentTiddler>get[due_year]] [<currentTiddler>get[due_month]] [<currentTiddler>get[due_day]] +[join[]] }}}
          >
          <h3> {{{ [<week_end>compare:number:gteq<sprint_start>compare:number:lteq<sprint_end>then<currentTiddler>] }}} </h3>
          </$let>
        </$list>
    
      </div>
    
        </$let>
    </$list>
    

    the concat i needed could be implemented by [join[]]