On Wednesday, April 22, 2020 at 11:30:41 AM UTC-7, si wrote:
>
> Hi everyone.
> I'm trying to implement a particular type of task list using plain 
> wikitext. I stole the idea from supermemo 
> <https://supermemo.guru/wiki/Tasklist>.
> Each of my tasks is tagged *task*, and has the fields *time *and *value*. 
> These fields represent the estimated time a task will take and the 
> perceived value of a task respectively.
> I'm trying to generate a task list that is sorted by the result of *value 
> divided by time* for each task.
> I thought this would be able to do this easily, then tried it and realised 
> I couldn't. Can anyone help me out here?
>

I did something similar to create a "tag cloud", where the tags are sorted 
by the number of tiddlers they are tagging.
See 
http://tiddlytools.com/filtergenerators.html#TiddlyTools%2FFilterGenerators%2FTagCloud

For your purposes, the code is actually quite a bit simpler than the 
TagCloud.  This should do the job:
\define getitems()
<$list filter="[tag[task]]">
   <$vars time={{!!time}} value={{!!value}}>
   <$text text="[["/>{{{ [<value>divide<time>] }}};<<currentTiddler>><$text 
text="]]"/>
   </$vars>
</$list>
\end

<$wikify name="items"  text=<<getitems>>  >
   <$list filter="[enlist<items>nsort[]]">
      {{{ [<currentTiddler>split[;]last[]] }}}<br>
   </$list>
</$wikify>

The <<getitems>> macro:
* gets all tiddlers tagged with "task"
* calculates the "value/time" number for each
* prepends that calculated value in front of each task title, separated by 
a semi-colon (;) and surrounded by double square brackets to handle titles 
with spaces

The calling code:
* Uses $wikify to capture the output of <<getitems>> into a variable, 
"items"
* The $list widget then enlists the items and sorts them numerically
* The output then strips off the calculated number and the semi-colon 
separator and displays the tiddler titles in the sorted order

Let me know how it goes...

enjoy,
-e


-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/3d79f8bd-ee44-401c-8186-e4fc4b1acf8a%40googlegroups.com.

Reply via email to