PasteRack.org | ||
Paste # 93106 | ||
2021-03-14 17:55:25 | ||
Fork as a new paste. | ||
Paste viewed 227 times. | ||
Tweet | ||
Embed: | ||
#lang racket ; Parameters that are valid for _all_ groups for a task field (struct group-params (; Task field symbol, e. g. 'priority ; task-field ; Function that converts a task field value to a group title, e. g. ; `(lambda (field-value) (string-append "+" field-value))` for project ; fields. ; ; The function will only be called for non-dummy field values, i. e. the ; function doesn't need to handle the case where, for example, we group by ; creation date and a task doesn't have a creation date. field-value->title ; Title for unset field, e. g. "No priority" unset-value-title) #:constructor-name group-params-struct ; Prevent `group-params` from being defined, so we can use the name ; `group-params` for the hash below. #:name unused-group-params #:transparent) (define (make-group-params unset-value-title . field-value->title) (group-params-struct (if (empty? field-value->title) (lambda (value) value) (first field-value->title)) unset-value-title)) (define group-params (hash 'completed? (make-group-params "Not completed" (lambda (value) "Completed")) 'priority (make-group-params "No priority") 'completion-date (make-group-params "No completion date") 'creation-date (make-group-params "No creation date") 'description (make-group-params "No description") 'projects (make-group-params "No projects" ; This will be called on one of the list items in the ; `projects` field. (lambda (value) (string-append "+" value))) 'contexts (make-group-params "No contexts" ; This will be called on one of the list items in the ; `contexts` field. (lambda (value) (string-append "@" value))) ; TODO Tags need special handling. We likely want to group by tag/value ; combinations, not just tag names. 'tags (make-group-params "No tags")))