update_time:2021-09-06 8:19 Mon

首先需知道目前「模板使用方法」:在 工作空间下 data/templates 文件夹新建一个 md 文件,命名,然后粘贴我给的代码,最终在思源用/斜杆菜单打开模板选择页面选择就好了

【模板】汇总今天更新或指定日期范围的文档 - 图1

截图:data/templates 文件夹(可以用一级文件夹管理模板)

【模板】汇总今天更新或指定日期范围的文档 - 图2

截图:斜杆菜单

【模板】汇总今天更新或指定日期范围的文档 - 图3

截图:选择模板

展示今天更新的笔记

updated_today_doc.md: 按更新时间倒序,以块引方式展示今天更新的文档

用途:每日总结等

如果按创建时间排序,把 sql 语句里的 updated 改成 created

注:sql 语句 我加了 Limit 语句限制查询为 10000 条,如果不加 Limit 只会展示数十条,但我不知道能否直接不限制查询结果,如果有知道的朋友请告知我,感谢!

  1. ## .action{ now | date "2006-01-02 Mon "} 今天更新的笔记文档
  2. .action{$today := now | date "20060102"}
  3. .action{$next := (now | date_modify "+24h")| date "20060102"}
  4. .action{$blocks :=queryBlocks "SELECT * FROM blocks WHERE id in (SELECT root_id FROM blocks WHERE root_id != '?' AND (created >= '?' AND created <= '?' OR updated >= '?' AND updated <= '?') ) order by HPath LIMIT -1" .id $today $next $today $next }
  5. .action{range $v := $blocks}
  6. - ((.action{$v.RootID} ".action{$v.HPath}"))
  7. .action{end}

updated_today_doc_link.md : 按更新时间倒序,以块超链接方式展示今天更新的文档

我多添加一个以块链接展示是因为我觉得有时候汇总性质的笔记并不需要使用到双链,增加无用的引用关系,用块超链接的形式展示可以节省计算资源,也能达到汇总目的,还可以复制到外部软件或网站。

  1. ## .action{ now | date "2006-01-02 Mon "} 今天更新的笔记文档
  2. .action{$today := now | date "20060102"}
  3. .action{$next := (now | date_modify "+24h")| date "20060102"}
  4. .action{$blocks :=queryBlocks "SELECT * FROM blocks WHERE id in (SELECT root_id FROM blocks WHERE root_id != '?' AND (created >= '?' AND created <= '?' OR updated >= '?' AND updated <= '?') ) order by HPath LIMIT -1" .id $today $next $today $next }
  5. .action{range $v := $blocks}
  6. - [.action{$v.HPath}](siyuan://blocks/.action{$v.ID})
  7. .action{end}

统计特点时间内更新的文档

7天内

updated_7day_doc_link.md

  1. ## .action{ now | date "2006-01-02 Mon "} 过去7天更新的笔记文档
  2. .action{$from := (now | date_modify "-144h") | date "20060102"}
  3. .action{$to := (now | date_modify "+24h") | date "20060102"}
  4. .action{/* 按文档名升序排列 */}
  5. .action{/* 按文档名升序排列 */}
  6. .action{$blocks :=queryBlocks "SELECT * FROM blocks WHERE id in (SELECT root_id FROM blocks WHERE root_id != '?' AND (created >= '?' AND created <= '?' OR updated >= '?' AND updated <= '?') ) order by HPath LIMIT -1" .id $from $to $from $to }
  7. .action{range $v := $blocks}
  8. - [.action{$v.HPath}](siyuan://blocks/.action{$v.ID})
  9. .action{end}

31天内

updated_31day_doc_link.md

  1. ## .action{ now | date "2006-01-02 Mon "} 过去31天更新的笔记文档:
  2. .action{$from := (now | date_modify "-720h") | date "20060102"}
  3. .action{$to := (now | date_modify "+24h") | date "20060102"}
  4. .action{/* 按文档名升序排列 */}
  5. .action{$blocks :=queryBlocks "SELECT * FROM blocks WHERE id in (SELECT root_id FROM blocks WHERE root_id != '?' AND (created >= '?' AND created <= '?' OR updated >= '?' AND updated <= '?') ) order by HPath LIMIT -1" .id $from $to $from $to }
  6. .action{range $v := $blocks}
  7. - [.action{$v.HPath}](siyuan://blocks/.action{$v.ID})
  8. .action{end}

自定义时间

自定义方法:只需要在开头修改 from 和 to 里的时间,“2021-08-01 00:00:00”和”2021-08-31 23:59:59”

用途:每周总结、每月总结等需求

updated_someday_doc_link.md 块超链接版本

  1. .action{/* 在这里更新查询的起始时间*/}
  2. .action{$from:= toDate "2006-01-02 15:04:05" "2022-03-01 00:00:00"}
  3. .action{$to := toDate "2006-01-02 15:04:05" "2022-03-31 23:59:59"}
  4. ## .action{$from | date "2006.01.02 Mon"} \~ .action{$to | date "2006.01.02 Mon"} 期间更新的笔记文档
  5. .action{$from:= $from | date "20060102150405"}
  6. .action{$to:= $to | date "20060102150405"}
  7. .action{/* 按文档名升序排列 */}
  8. .action{$blocks :=queryBlocks "SELECT * FROM blocks WHERE id in (SELECT root_id FROM blocks WHERE root_id != '?' AND (created >= '?' AND created <= '?' OR updated >= '?' AND updated <= '?') ) order by HPath LIMIT -1" .id $from $to $from $to }
  9. .action{range $v := $blocks}
  10. - [.action{$v.HPath}](siyuan://blocks/.action{$v.ID})
  11. .action{end}

更多关于模板的使用见语雀:📋模板使用基本介绍 · 语雀 (yuque.com)